getFileNameFromHeaders = (headers) => {
const disposition = headers['content-disposition']
let fileName = '未命名'
try {
fileName = disposition.split(';')[1].split('filename=')[1]
const fileNameUnicode = disposition.split('filename*=')[1]
if (fileNameUnicode) {
fileName = decodeURIComponent(fileNameUnicode.split("''")[1])
}
} catch (error) {
console.error('getFileNameFromHeaders:', error)
}
return fileName
}
标签:接口,fileName,header,split,disposition,error,filename,fileNameUnicode
From: https://www.cnblogs.com/luckyitape/p/17138211.html