【发布时间】:2019-01-08 21:00:38
【问题描述】:
我无法在 react-native 中从 url 下载图像,我使用的是“react-native-fetch-blob”,它适用于 android 但不适用于 iOS。 让 PictureDir = fs.dirs.PictureDir; 这是 iOS 未定义的 PicureDir。
代码如下:
const { config, fs } = RNFetchBlob;
let PictureDir = Platform.OS === 'ios' ? fs.dirs.DocumentDir : fs.dirs.PictureDir;
let options = {
fileCache: true,
addAndroidDownloads : {
useDownloadManager : true, // setting it to true will use the device's native download manager and will be shown in the notification bar.
notification : false,
path: PictureDir + "/me_"+Math.floor(date.getTime() + date.getSeconds() / 2), // this is the path where your downloaded file will live in
description : 'Downloading image.'
}
}
config(options).fetch('GET', "https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?cs=srgb&dl=beauty-bloom-blue-67636.jpg&fm=jpg").then((res) => {
}) ;
【问题讨论】:
标签: ios file react-native url download