@shapediver/sdk.geometry-api-sdk-v2
Advanced tools
Comparing version 1.7.0 to 1.8.0
import { ShapeDiverRequestFileUpload, ShapeDiverResponseDto } from "@shapediver/api.geometry-api-dto-v2"; | ||
import { BaseResourceApi, ShapeDiverSdkApi } from "@shapediver/sdk.geometry-api-sdk-core"; | ||
export interface ShapeDiverResponseFileInfo { | ||
filename?: string; | ||
size?: number; | ||
} | ||
export declare class ShapeDiverFileApi extends BaseResourceApi { | ||
constructor(api: ShapeDiverSdkApi); | ||
list(sessionId: string, paramId: string): Promise<ShapeDiverResponseDto>; | ||
info(sessionId: string, paramId: string, fileId: string): Promise<ShapeDiverResponseFileInfo>; | ||
get(sessionId: string, paramId: string, fileId: string): Promise<ArrayBuffer>; | ||
@@ -7,0 +12,0 @@ delete(sessionId: string, paramId: string, fileId: string): Promise<ShapeDiverResponseDto>; |
@@ -21,5 +21,26 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { return (yield this.api.get(`${this.buildSessionUri(sessionId)}/file/${paramId}/list`))[1]; })); | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.api.get(`${this.buildSessionUri(sessionId)}/file/${paramId}/list`))[1]; | ||
})); | ||
}); | ||
} | ||
info(sessionId, paramId, fileId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { | ||
const headers = (yield this.api.head(`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`))[0]; | ||
const res = { | ||
size: Number(headers.get("Content-Length") || headers.get("content-length")), | ||
}; | ||
const contentDisposition = headers.get("Content-Disposition") | ||
|| headers.get("content-disposition"); | ||
if (typeof contentDisposition === "string" && | ||
contentDisposition.indexOf("=") > 0) { | ||
res.filename = contentDisposition | ||
.split("=")[1] | ||
.slice(1, -1); | ||
} | ||
return res; | ||
})); | ||
}); | ||
} | ||
get(sessionId, paramId, fileId) { | ||
@@ -34,3 +55,5 @@ return __awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { return (yield this.api.delete(`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`))[1]; })); | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.api.delete(`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`))[1]; | ||
})); | ||
}); | ||
@@ -40,3 +63,5 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { return (yield this.api.post(this.buildSessionUri(sessionId) + "/file/upload", body))[1]; })); | ||
return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { | ||
return (yield this.api.post(this.buildSessionUri(sessionId) + "/file/upload", body))[1]; | ||
})); | ||
}); | ||
@@ -43,0 +68,0 @@ } |
@@ -7,3 +7,3 @@ import { ShapeDiverRequestCustomization, ShapeDiverRequestExport, ShapeDiverResponseDto } from "@shapediver/api.geometry-api-dto-v2"; | ||
constructor(api: ShapeDiverSdkApi); | ||
upload(url: string, data: ArrayBuffer | Record<string, any> | string, contentType: string): Promise<any>; | ||
upload(url: string, data: ArrayBuffer | Record<string, any> | string, contentType: string, filename?: string): Promise<any>; | ||
download<T extends ShapeDiverSdkApiResponseType>(url: string, responseType: T): Promise<[ | ||
@@ -10,0 +10,0 @@ Record<string, any>, |
@@ -19,3 +19,3 @@ "use strict"; | ||
} | ||
upload(url, data, contentType) { | ||
upload(url, data, contentType, filename) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -25,2 +25,3 @@ return yield (0, utils_1.sendRequest)(() => __awaiter(this, void 0, void 0, function* () { | ||
contentType: contentType, | ||
contentDisposition: (filename) ? `attachment; filename="${filename}"` : undefined, | ||
responseType: sdk_geometry_api_sdk_core_1.ShapeDiverSdkApiResponseType.JSON, | ||
@@ -27,0 +28,0 @@ disableAuthorization: true, |
{ | ||
"name": "@shapediver/sdk.geometry-api-sdk-v2", | ||
"version": "1.7.0", | ||
"version": "1.8.0", | ||
"description": "SDK to communicate with the Geometry API version 2", | ||
@@ -56,5 +56,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@shapediver/sdk.geometry-api-sdk-core": "~1.3.2", | ||
"@shapediver/api.geometry-api-dto-v2": "~1.13.0" | ||
"@shapediver/sdk.geometry-api-sdk-core": "~1.4.0", | ||
"@shapediver/api.geometry-api-dto-v2": "~1.14.1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
123872
1233
+ Added@shapediver/api.geometry-api-dto-v2@1.14.1(transitive)
+ Added@shapediver/sdk.geometry-api-sdk-core@1.4.0(transitive)
- Removed@shapediver/api.geometry-api-dto-v2@1.13.0(transitive)
- Removed@shapediver/sdk.geometry-api-sdk-core@1.3.2(transitive)