quasar-ui-danx 0.3.38 → 0.3.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/danx.es.js +16 -11
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +2 -2
- package/dist/danx.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/FileUpload.ts +36 -29
package/package.json
CHANGED
@@ -270,36 +270,43 @@ export class FileUpload {
|
|
270
270
|
async upload() {
|
271
271
|
console.log && console.log("FileUploader@upload():", this.fileUploads, this.options);
|
272
272
|
for (const fileUpload of this.fileUploads) {
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
273
|
+
try {
|
274
|
+
const mimeType = fileUpload.file.mimeType || fileUpload.file.type;
|
275
|
+
const presignedUrl = this.options.presignedUploadUrl(this.options.directory, fileUpload.file.name, mimeType);
|
276
|
+
|
277
|
+
console.log("calling presigned URL", presignedUrl);
|
278
|
+
|
279
|
+
// Fetch presigned upload URL
|
280
|
+
const fileResource = await fetch(presignedUrl).then(r => r.json());
|
281
|
+
|
282
|
+
if (!fileResource.url) {
|
283
|
+
FlashMessages.error("Could not fetch presigned upload URL for file " + fileUpload.file.name);
|
284
|
+
continue;
|
285
|
+
}
|
286
|
+
|
287
|
+
const isS3Upload = !fileResource.url.match("upload-presigned-url-contents");
|
288
|
+
|
289
|
+
// We need the file resource ID to complete the presigned upload
|
290
|
+
fileUpload.file.resource_id = fileResource.id;
|
291
|
+
|
292
|
+
// Prepare XHR request
|
293
|
+
const xhr = new XMLHttpRequest();
|
294
|
+
|
295
|
+
// The XHR request is different based on weather we're sending to S3 or the platform server
|
296
|
+
if (isS3Upload) {
|
297
|
+
xhr.open("PUT", fileResource.url);
|
298
|
+
xhr.setRequestHeader("Content-Type", mimeType);
|
299
|
+
fileUpload.body = fileUpload.file;
|
300
|
+
} else {
|
301
|
+
xhr.open("POST", fileResource.url);
|
302
|
+
fileUpload.body = fileUpload.formData;
|
303
|
+
}
|
304
|
+
|
305
|
+
fileUpload.xhr = xhr;
|
306
|
+
} catch (error) {
|
307
|
+
console.error && console.error("FileUploader@upload():", "Failed to fetch presigned upload URL", error);
|
308
|
+
this.errorHandler(null, fileUpload.file, error);
|
300
309
|
}
|
301
|
-
|
302
|
-
fileUpload.xhr = xhr;
|
303
310
|
}
|
304
311
|
|
305
312
|
// Set all the callbacks on the XHR requests
|