我使用的是rn-fetch-blob,如何下载需要通过POST在请求体中传递一些参数的文件?我试过了:
RNFetchBlob
.config({
// add this option that makes response data to be stored as a file,
// this is much more performant.
fileCache: true,
path: RNFetchBlob.fs.dirs.DownloadDir + '/video.mp4'
})
.fetch('POST', `${SERVER}/get_video`, {
unique_key: TerminalID(),
id_midia: '2'
})
.then((res) => {
// the temp file path
Alert.alert('Caminho', 'The file saved to ' + res.path())
this.setState({ download: true, downloadActionFinished: true })
})但是API没有收到我在请求体上传递的数据
发布于 2019-02-06 21:57:49
你基本上没有在你的请求中附加正文:
fetch(method, url, headers, body)发布于 2019-05-03 18:52:20
var tempParam = [{name: 'image',filename: 'image.jpg',data: RNFetchBlob.wrap(uri}]name是关键。如果您向API发送文件,则需要使用filename。包装文件数据的方法可以在fetch API上找到(如果我没有错的话)
https://stackoverflow.com/questions/54554436
复制相似问题