Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Better Error Handling during Upload Failure and Setting Max File Leng…
Browse files Browse the repository at this point in the history
…th to Infinity
  • Loading branch information
wk93210 committed Sep 14, 2021
1 parent 8da05fe commit 59eb85c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugins/songUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ module.exports = async (query, request) => {
)

// 上传
const objectKey = tokenRes.body.result.objectKey.replace('/', '%2F')
try {
await axios({
method: 'post',
url: `http://45.127.129.8/jd-musicrep-privatecloud-audio-public/${objectKey}?offset=0&complete=true&version=1.0`,
url: tokenRes.body.result.outerUrl,
headers: {
'x-nos-token': tokenRes.body.result.token,
'Content-MD5': query.songFile.md5,
'Content-Type': 'audio/mpeg',
'Content-Length': String(query.songFile.size),
},
data: query.songFile.data,
maxContentLength: Infinity,
maxBodyLength: Infinity,
})
} catch (error) {
console.log('error', error.response)
throw error.response
}
return {
...tokenRes,
Expand Down

0 comments on commit 59eb85c

Please sign in to comment.