update download att
This commit is contained in:
parent
527028bc58
commit
0f2b655a17
@ -278,9 +278,9 @@ export default {
|
||||
this.mnx_backendErrorHandler(error)
|
||||
})
|
||||
},
|
||||
downloadAttachedFile(request_id, document_id) {
|
||||
downloadAttachedFile(request_id, document_id, file_name) {
|
||||
|
||||
window.open(`http://${window.location.host}/api/workspace/request/fetch-attached-file-as-download?request_id=${request_id}&document_id=${document_id}`)
|
||||
// window.open(`http://${window.location.host}/api/workspace/request/fetch-attached-file-as-download?request_id=${request_id}&document_id=${document_id}`)
|
||||
|
||||
// const link = document.createElement('a')
|
||||
// link.href = `${window.location.host}/api/workspace/request/fetch-attached-file-as-download?request_id=${request_id}&document_id=${document_id}`
|
||||
@ -290,26 +290,27 @@ export default {
|
||||
// link.click()
|
||||
// document.body.removeChild(link)
|
||||
|
||||
// WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id)
|
||||
// .then((response) => {
|
||||
// // create file link in browser's memory
|
||||
// const href = URL.createObjectURL(response.data)
|
||||
WorksapceApi.fetchAttachedFileAsDownload(request_id, document_id)
|
||||
.then((response) => {
|
||||
console.log('resposne', response)
|
||||
// create file link in browser's memory
|
||||
// const href = URL.createObjectURL(response.data)
|
||||
|
||||
// // create "a" HTML element with href to file & click
|
||||
// const link = document.createElement('a')
|
||||
// link.href = href
|
||||
// link.setAttribute('download', 'file.pdf') //or any other extension
|
||||
// link.setAttribute('_')
|
||||
// document.body.appendChild(link)
|
||||
// link.click()
|
||||
// create "a" HTML element with href to file & click
|
||||
const link = document.createElement('a')
|
||||
link.href = response.data.download_url
|
||||
link.download = file_name
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
|
||||
// // clean up "a" element & remove ObjectURL
|
||||
// document.body.removeChild(link)
|
||||
// URL.revokeObjectURL(href) //TODO: navigate to the preview page
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// this.mnx_backendErrorHandler(error)
|
||||
// })
|
||||
// clean up "a" element & remove ObjectURL
|
||||
document.body.removeChild(link)
|
||||
// URL.revokeObjectURL(href) //TODO: navigate to the preview page
|
||||
})
|
||||
.catch((error) => {
|
||||
this.mnx_backendErrorHandler(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user