Skip to content

Commit

Permalink
✨ 浏览器端也支持 basename
Browse files Browse the repository at this point in the history
  • Loading branch information
di4urp committed Jul 15, 2019
1 parent 89c9555 commit ce41791
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions upyun/browser-form-upload.js
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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) {
Expand Down

0 comments on commit ce41791

Please sign in to comment.