quasar-ui-danx 0.3.39 → 0.3.41
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/package.json
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
import { PlusIcon } from "@heroicons/vue/outline";
|
25
25
|
import { QBtn } from "quasar";
|
26
26
|
import { ref } from "vue";
|
27
|
-
import { FileUpload } from "../../../../helpers";
|
27
|
+
import { downloadFile, fDateTime, FileUpload, sleep } from "../../../../helpers";
|
28
28
|
|
29
29
|
defineExpose({ upload });
|
30
30
|
const emit = defineEmits([
|
@@ -44,7 +44,12 @@ const props = defineProps({
|
|
44
44
|
default: "Waiting for location..."
|
45
45
|
},
|
46
46
|
cameraOnly: Boolean,
|
47
|
-
geolocation: Boolean
|
47
|
+
geolocation: Boolean,
|
48
|
+
autoDownloadCapture: Boolean,
|
49
|
+
downloadName: {
|
50
|
+
type: String,
|
51
|
+
default: "Upload"
|
52
|
+
}
|
48
53
|
});
|
49
54
|
|
50
55
|
const fileUpload = ref(null);
|
@@ -61,6 +66,10 @@ function upload() {
|
|
61
66
|
*/
|
62
67
|
async function onAttachFiles({ target: { files } }) {
|
63
68
|
console.log("files attached", files);
|
69
|
+
if (props.autoDownloadCapture) {
|
70
|
+
await saveFilesLocally(files);
|
71
|
+
}
|
72
|
+
console.log("uploading files");
|
64
73
|
emit("uploading", files);
|
65
74
|
let fileUpload = new FileUpload(files)
|
66
75
|
.onProgress(({ file, progress }) => {
|
@@ -83,4 +92,20 @@ async function onAttachFiles({ target: { files } }) {
|
|
83
92
|
|
84
93
|
fileUpload.upload();
|
85
94
|
}
|
95
|
+
|
96
|
+
|
97
|
+
async function saveFilesLocally(files) {
|
98
|
+
// Make sure the blob URL is set before saving
|
99
|
+
await sleep(10);
|
100
|
+
|
101
|
+
for (let file of files) {
|
102
|
+
let fileName = props.downloadName + "-" + fDateTime(null, { format: " M-d-yy h:mm a" });
|
103
|
+
if (file.name) {
|
104
|
+
fileName += "__" + file.name;
|
105
|
+
} else {
|
106
|
+
fileName += "." + (file.mime || file.type).split("/").pop() || "jpg";
|
107
|
+
}
|
108
|
+
await downloadFile(file.blobUrl, fileName);
|
109
|
+
}
|
110
|
+
}
|
86
111
|
</script>
|
@@ -279,6 +279,8 @@ export class FileUpload {
|
|
279
279
|
// Fetch presigned upload URL
|
280
280
|
const fileResource = await fetch(presignedUrl).then(r => r.json());
|
281
281
|
|
282
|
+
console.log("loaded presignedUrl: fileResource", fileResource);
|
283
|
+
|
282
284
|
if (!fileResource.url) {
|
283
285
|
FlashMessages.error("Could not fetch presigned upload URL for file " + fileUpload.file.name);
|
284
286
|
continue;
|
@@ -294,7 +296,9 @@ export class FileUpload {
|
|
294
296
|
|
295
297
|
// The XHR request is different based on weather we're sending to S3 or the platform server
|
296
298
|
if (isS3Upload) {
|
299
|
+
console.log("uploading S3", xhr);
|
297
300
|
xhr.open("PUT", fileResource.url);
|
301
|
+
console.log("setting content type to", mimeType);
|
298
302
|
xhr.setRequestHeader("Content-Type", mimeType);
|
299
303
|
fileUpload.body = fileUpload.file;
|
300
304
|
} else {
|