@acceleratxr/core_sdk
Advanced tools
Comparing version
@@ -38,3 +38,3 @@ "use strict"; | ||
/** | ||
* Uploads the given form data and creates a new asset. | ||
* Uploads file(s) in the given form data and creates new assets. | ||
*/ | ||
@@ -45,31 +45,7 @@ create(form) { | ||
if (url) { | ||
const response = yield this.apiClient.send(url, "POST", form, undefined, { | ||
"Content-Type": `multipart/form-data; boundary=${form.getBoundary()}` | ||
}); | ||
const result = response.data ? new models_1.Asset(response.data) : undefined; | ||
if (result) { | ||
Object.defineProperty(result, "remoteUrl", { | ||
value: url + "/" + result.uid, | ||
writable: true, | ||
enumerable: false, | ||
}); | ||
} | ||
return result; | ||
} | ||
else { | ||
throw new Error((0, i18n_1.typedT)('axr_sdk.errors.failed_retrieve_service_path')); | ||
} | ||
}); | ||
} | ||
/** | ||
* Uploads all files in the given form data and creates a new asset for each. | ||
*/ | ||
createMany(form) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
let url = this.config.getBaseServicePath(AssetService); | ||
if (url) { | ||
const response = yield this.apiClient.send(url, "POST", form); | ||
const response = yield this.apiClient.send(url, "POST", form, undefined, Object.assign({}, form.getHeaders())); | ||
const result = response.data ? [] : undefined; | ||
if (result) { | ||
for (const data of response.data) { | ||
let uploads = (Array.isArray(response.data) ? response.data : [response.data]); | ||
for (const data of uploads) { | ||
const asset = new models_1.Asset(data); | ||
@@ -76,0 +52,0 @@ Object.defineProperty(asset, "remoteUrl", { |
@@ -14,10 +14,6 @@ import { ServiceBase } from "../ServiceBase"; | ||
/** | ||
* Uploads the given form data and creates a new asset. | ||
* Uploads file(s) in the given form data and creates new assets. | ||
*/ | ||
create(form: FormData): Promise<Asset | undefined>; | ||
create(form: FormData): Promise<Asset[] | undefined>; | ||
/** | ||
* Uploads all files in the given form data and creates a new asset for each. | ||
*/ | ||
createMany(form: FormData): Promise<Asset[] | undefined>; | ||
/** | ||
* Deletes all assets from the service. | ||
@@ -24,0 +20,0 @@ */ |
{ | ||
"name": "@acceleratxr/core_sdk", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0-rc.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "Jean-Philippe Steinmetz <info@acceleratxr.com>", |
Sorry, the diff of this file is not supported yet
5738916
-0.03%214790
-0.01%