Skip to content

Commit ce41791

Browse files
committed
✨ 浏览器端也支持 basename
1 parent 89c9555 commit ce41791

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

upyun/browser-form-upload.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios'
2+
import path from 'path'
23

34
export default function formUpload (remoteUrl, localFile, {authorization, policy}, {filename} = {}) {
45
const data = new FormData()
@@ -8,6 +9,7 @@ export default function formUpload (remoteUrl, localFile, {authorization, policy
89
localFile = new Blob([localFile], {type: 'text/plain'})
910
}
1011

12+
filename = filename ? path.basename(filename) : filename
1113
data.append('file', localFile, filename)
1214
return axios.post(remoteUrl, data).then(({status, data}) => {
1315
if (status === 200) {

0 commit comments

Comments
 (0)