就實現下載功能一小時前:對
遵循以下步驟:
一)NPM安裝反應原生取二進制大對象 二)按照安裝說明。 b2)如果您想要在不使用rnpm的情況下手動安裝軟件包,請轉至其wiki。 三)最後,這就是我提出可以將我的應用程序中下載文件:
const { config, fs } = RNFetchBlob
let PictureDir = fs.dirs.PictureDir // this is the pictures directory. You can check the available directories in the wiki.
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', "http://www.example.com/example.pdf").then((res) => {
// do some magic here
})
非常感謝:) – Arnaud