upload-sound-file
v1.0.0
Published
上传文件,自定义接口,类型,格式,token,请求头
Downloads
1
Readme
快速上手
安装 upload-sound-file
npm install upload-sound-file
引入 upload-sound-file
import uploadSoundFile from 'upload-sound-file';
如果你使用原生方法,可以通过标签引用
<script src="./upload-sound-file.js"></script>
开始使用
需要自定义 携带多个头部信息
const postRecording = (file, time) => {
let customHeader = {
'content-type': 'application/json',
'user': 'qingci',
};
uploadSoundFile("/xxx/upload/single", file, 'mp3', token, undefined, customHeader)
.then((data) => {
}).catch((res) => {
})
}
需要自定义 携带一个头部信息
const postRecording = (file, time) => {
uploadSoundFile("/xxx/upload/single", file, 'mp3', token, 'authorization')
.then((data) => {
}).catch((res) => {
})
}
使用默认头部信息 { 'Content-Type': 'multipart/form-data' },且不需要token
const postRecording = (file, time) => {
uploadSoundFile("/xxx/upload/single", file, 'mp3')
.then((data) => {
}).catch((res) => {
})
}