Editable submission File input support (#120)

This commit is contained in:
Chirag Chhatrala
2023-04-26 20:35:02 +05:30
committed by GitHub
parent 3f2fe352e8
commit e165242e57
4 changed files with 44 additions and 4 deletions

View File

@@ -208,7 +208,19 @@ export default {
}
},
created () {
async created () {
if(this.compVal && this.compVal.length > 0) {
let tmpFiles = []
for (let i = 0; i < this.compVal.length; i++) {
await this.getFileFromUrl(this.compVal[i]).then((fileObj) => {
tmpFiles.push({
file: fileObj,
url: this.compVal[i]
})
})
}
this.files = tmpFiles
}
},
methods: {
@@ -262,6 +274,14 @@ export default {
this.showUploadModal = false
this.loading = false
})
},
async getFileFromUrl(url, defaultType='image/jpeg'){
const response = await fetch(url)
const data = await response.blob()
const name = url.replace(/^.*(\\|\/|\:)/, '')
return new File([data], name, {
type: data.type || defaultType,
})
}
}
}