Javascript 如何通过IOS上的react native将视频从我的应用下载到照片
我通过Javascript 如何通过IOS上的react native将视频从我的应用下载到照片,javascript,reactjs,react-native,ecmascript-6,Javascript,Reactjs,React Native,Ecmascript 6,我通过rn fetch bloblibrary创建了将视频从url下载到本地存储的功能,它在android fine上工作,但在ios上不工作 我通过xcode添加了persmission,但当我打开照片或相机卷时,我找不到视频 async download() { this.setState({btnDownloadLoading: true}); const {video} = this.state; let hasPermission =
rn fetch blob
library创建了将视频从url下载到本地存储的功能,它在android fine上工作,但在ios上不工作
我通过xcode添加了persmission,但当我打开照片或相机卷时,我找不到视频
async download() {
this.setState({btnDownloadLoading: true});
const {video} = this.state;
let hasPermission = await this.requestStoragePermission();
console.log('hasPermission : ', hasPermission);
if (!hasPermission) {
this.requestStoragePermission();
this.setState({btnDownloadLoading: false});
return false;
}
var date = new Date();
var url = video.video_url;
var ext = this.extention(url);
ext = "." + ext[0];
const {config, fs} = RNFetchBlob
let MovieDir = fs.dirs.DownloadDir
let options = {
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
path: MovieDir + "/video_" + Math.floor(date.getTime() + date.getSeconds() / 2) + ext,
description: 'Video'
}
}
config(options).fetch('GET', url).then((res) => {
this.setState({btnDownloadLoading: false});
Alert.alert("تم تحميل الفيديو بنجاح.");
});
}
我需要在ios和android上运行的代码,以便将视频从url下载到我的手机上您可以使用cameraRoll保存图像
CameraRoll.saveToCameraRoll(filePath, 'photo')
.then(Alert.alert('Success', ' added to camera roll!'))
它对我有用