quasar-ui-danx 0.3.38 → 0.3.40
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 +40 -29
package/package.json
CHANGED
@@ -270,36 +270,47 @@ 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
|
-
xhr
|
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
|
+
console.log("loaded presignedUrl: fileResource", fileResource);
|
283
|
+
|
284
|
+
if (!fileResource.url) {
|
285
|
+
FlashMessages.error("Could not fetch presigned upload URL for file " + fileUpload.file.name);
|
286
|
+
continue;
|
287
|
+
}
|
288
|
+
|
289
|
+
const isS3Upload = !fileResource.url.match("upload-presigned-url-contents");
|
290
|
+
|
291
|
+
// We need the file resource ID to complete the presigned upload
|
292
|
+
fileUpload.file.resource_id = fileResource.id;
|
293
|
+
|
294
|
+
// Prepare XHR request
|
295
|
+
const xhr = new XMLHttpRequest();
|
296
|
+
|
297
|
+
// The XHR request is different based on weather we're sending to S3 or the platform server
|
298
|
+
if (isS3Upload) {
|
299
|
+
console.log("uploading S3", xhr);
|
300
|
+
xhr.open("PUT", fileResource.url);
|
301
|
+
console.log("setting content type to", mimeType);
|
302
|
+
xhr.setRequestHeader("Content-Type", mimeType);
|
303
|
+
fileUpload.body = fileUpload.file;
|
304
|
+
} else {
|
305
|
+
xhr.open("POST", fileResource.url);
|
306
|
+
fileUpload.body = fileUpload.formData;
|
307
|
+
}
|
308
|
+
|
309
|
+
fileUpload.xhr = xhr;
|
310
|
+
} catch (error) {
|
311
|
+
console.error && console.error("FileUploader@upload():", "Failed to fetch presigned upload URL", error);
|
312
|
+
this.errorHandler(null, fileUpload.file, error);
|
300
313
|
}
|
301
|
-
|
302
|
-
fileUpload.xhr = xhr;
|
303
314
|
}
|
304
315
|
|
305
316
|
// Set all the callbacks on the XHR requests
|