add: file upload logic

v0.4
rrr-marble 3 years ago
parent b1a5adfdf3
commit 47caa8cd26

@ -76,7 +76,7 @@ export default {
},
getPreviewPath(){
for (let extension of ["jpg", "png", "bmp"]) {
const path = `${this.baseURL}/static/previews/${this.itemDetails.fadr}+/${this.itemDetails.internal_id}.${extension}`
const path = `/static/previews/${this.itemDetails.fadr}+/${this.itemDetails.internal_id}.${extension}`
fetch(path, {method: 'HEAD'})
.then(resp => {
if (resp.status === 200) {
@ -86,7 +86,7 @@ export default {
.catch(e => {
// 404 are expected here, so ignore it
if (e.status !== 404){
//console.log(e)
console.log(e)
}
})
}

@ -2,7 +2,7 @@
<div>
<h1 style="font-size: 3rem; margin: 1rem;">Upload</h1>
<div class="upload-dashboard">
<va-file-upload dropzone></va-file-upload>
<va-file-upload dropzone type="single" @file-added="handleFile"></va-file-upload>
</div>
</div>
</template>
@ -10,7 +10,25 @@
<script>
export default {
name: "upload-screen"
name: "upload-screen",
data() {
return {
response: {},
showModal: false,
}
},
methods: {
handleFile(files) {
const formData = new FormData();
formData.append('file', files[0], files[0].name);
fetch("/api/v1/items/", {method: 'POST', body: formData})
.then(res => res.json())
.then(data => this.response = data)
.catch((e) => console.log(e))
.then(()=>console.log(this.response))
}
},
}
</script>

Loading…
Cancel
Save