Commit 5c1e20ac authored by 盖献康's avatar 盖献康

公用文件下载方法

parent 614c3480
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
}) })
}, },
resource(resource) { resource(resource) {
var url = baseURL + '/common/download/resource?resource=' + encodeURIComponent(resource) var url = baseURL + 'business/common/downloadMinio?url=' + encodeURIComponent(resource)
axios({ axios({
method: 'get', method: 'get',
url: url, url: url,
...@@ -36,7 +36,16 @@ export default { ...@@ -36,7 +36,16 @@ export default {
const isBlob = blobValidate(res.data) const isBlob = blobValidate(res.data)
if (isBlob) { if (isBlob) {
const blob = new Blob([res.data]) const blob = new Blob([res.data])
this.saveAs(blob, decodeURIComponent(res.headers['download-filename'])) const url = res.config['url']
const keyword = '-'
const index = url.indexOf(keyword, url.indexOf(keyword, url.indexOf(keyword) + 1) + 1)
let result = ''
if (index !== -1) {
result = url.substring(index + keyword.length)
} else {
return 'aa.pdf'
}
this.saveAs(blob, result)
} else { } else {
this.printErrMsg(res.data) this.printErrMsg(res.data)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment