React native压缩视频文件

时间:2017-07-24 14:02:22

标签: react-native

我在停止录制后使用react-native-camera录制视频我要压缩视频并上传到服务器。我使用react-native-zip-archive但我得到的压缩文件总是空的。知道如何正确压缩文件吗?

this.camera.capture({mode: Camera.constants.CaptureMode.video})
          .then((data) => {
        return zip(sourcePath, targetPath)
        .then((path) => {
            console.log(`zip completed at ${path}`);
            return RNFetchBlob.fetch('POST','https://server/upload', {
                'Content-Type': 'multipart/form-data',
                }, [
                    { name : 'video-comperss', filename : 'video-comperss', type:'video/quicktime', data: RNFetchBlob.wrap(path)},
                ])
                .then((res) => {
                    if (res.respInfo.status === 200) {
                        console.log('done');
                    }
                    return RNFS.unlink(targetPath)
                    .then(() => {
                        console.log('file deleted');
                    });
                });
            })
        })
        .catch(err => console.error(err));

0 个答案:

没有答案