diff --git a/upyun/browser-form-upload.js b/upyun/browser-form-upload.js index 9f6d2b8..445f973 100644 --- a/upyun/browser-form-upload.js +++ b/upyun/browser-form-upload.js @@ -1,4 +1,5 @@ import axios from 'axios' +import path from 'path' export default function formUpload (remoteUrl, localFile, {authorization, policy}, {filename} = {}) { const data = new FormData() @@ -8,6 +9,7 @@ export default function formUpload (remoteUrl, localFile, {authorization, policy localFile = new Blob([localFile], {type: 'text/plain'}) } + filename = filename ? path.basename(filename) : filename data.append('file', localFile, filename) return axios.post(remoteUrl, data).then(({status, data}) => { if (status === 200) {