progress
This commit is contained in:
parent
65db932232
commit
d16457a104
|
@ -223,10 +223,10 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
id="upload-modal" style="position: absolute; right:0; bottom: 20; background: white;z-index: 9999;">
|
id="upload-modal" style="position: absolute; right:0; bottom: 0; background: white;z-index: 9999;">
|
||||||
<template x-data x-if="$store.uploader.files.length > 0">
|
<template x-data x-if="$store.uploader.files.length > 0">
|
||||||
<template x-data x-for="file in $store.uploader.files">
|
<template x-data x-for="file in $store.uploader.files">
|
||||||
<p x-text="file"></p>
|
<p x-text="file.name"></p>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -239,11 +239,15 @@
|
||||||
console.log(this.files);
|
console.log(this.files);
|
||||||
},
|
},
|
||||||
async uploadFile(target) {
|
async uploadFile(target) {
|
||||||
/* console.dir(event.target); */
|
|
||||||
const formData = new FormData(target);
|
const formData = new FormData(target);
|
||||||
console.dir(formData.get('file'));
|
|
||||||
const sdk = window.ls.container.get('sdk');
|
const sdk = window.ls.container.get('sdk');
|
||||||
console.log(JSON.parse(formData.get('read')));
|
const file = formData.get('file');
|
||||||
|
this.files.push({
|
||||||
|
name: file.name,
|
||||||
|
progress: 0,
|
||||||
|
completed: false,
|
||||||
|
failed: false,
|
||||||
|
});
|
||||||
let read = formData.get('read');
|
let read = formData.get('read');
|
||||||
if(read) {
|
if(read) {
|
||||||
read = JSON.parse(read);
|
read = JSON.parse(read);
|
||||||
|
@ -253,13 +257,26 @@
|
||||||
if(write) {
|
if(write) {
|
||||||
write = JSON.parse(wirte);
|
write = JSON.parse(wirte);
|
||||||
}
|
}
|
||||||
const file = await sdk.storage.createFile(
|
const response = await sdk.storage.createFile(
|
||||||
formData.get('bucketId'),
|
formData.get('bucketId'),
|
||||||
formData.get('fileId'),
|
formData.get('fileId'),
|
||||||
formData.get('file'),
|
formData.get('file'),
|
||||||
read,
|
read,
|
||||||
write);
|
write,
|
||||||
this.files.push(file.name);
|
(progress) => {
|
||||||
|
this.files.push({
|
||||||
|
name: file.name,
|
||||||
|
progress: progress,
|
||||||
|
completed: false,
|
||||||
|
failed: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
this.files.push({
|
||||||
|
name: response.name,
|
||||||
|
progress: 100,
|
||||||
|
completed: true,
|
||||||
|
failed: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue