我想上传数据块到服务器,同时录制视频(而不是在录制之后)。我试着和react-native-camera或react-native-vision-camera一起去。
但据我所知,recordAsync方法只解决录制视频的最终版本。
有什么聪明的方法可以在录制过程中获取视频块或视频流吗?
或者我应该使用react本机-fs或rn-fetch-blob之类的?
==更新==
我可能会像在下面的链接中所做的那样来实现它。
发布于 2022-01-12 05:03:52
如果您的问题是上传一个大文件到服务器,也许您可以使用反应-本机-背景-上传,并显示进度通知,这将上传文件,即使是在应用程序的背景。
还有一个包,在chunck中,可以通过将文件分解成多个块来上传:react本机-块-上传。
import ChunkUpload from 'react-native-chunk-upload';
const chunk = new ChunkUpload({
path: response.path, // Path to the file
size: 10095, // Chunk size (must be multiples of 3)
fileName: response.fileName, // Original file name
fileSize: response.size, // Original file size
// Errors
onFetchBlobError: (e) => console.log(e),
onWriteFileError: (e) => console.log(e),
});
chunk.digIn(this.upload.bind(this));
upload(file, next, retry, unlink) {
const body = new FormData();
body.append('video', file.blob); // param name
axios.post('url', body, {
headers: {
"Content-Type": "multipart/form-data",
"Accept": 'application/json',
// Customize the headers
"x-chunk-number": file.headers["x-chunk-number"],
"x-chunk-total-number": file.headers["x-chunk-total-number"],
"x-chunk-size": file.headers["x-chunk-size"],
"x-file-name": file.headers["x-file-name"],
"x-file-size": file.headers["x-file-size"],
"x-file-identity": file.headers["x-file-identity"]
}
}).then((res) => {
...
})https://stackoverflow.com/questions/70676379
复制相似问题