如何将pdf文件保存到手机内部存储中?世博+ React Native

时间:2020-06-17 20:23:54

标签: react-native expo

我实际上正在使用此代码

const pdfGenerator = async () => {
        try {
            FileSystem.downloadAsync(
                `http://${api}`,
                FileSystem.documentDirectory + `${_id}.pdf`
            ).then(async ({ uri }) => {
                try {
                    const assetFile = await MediaLibrary.createAssetAsync(uri)
                    console.log(assetFile)
                   const album =  await MediaLibrary.createAlbumAsync("Arq", assetFile, false)
                   console.log(album)
                } catch (error) {
                    console.log(error)
                }
            })
            .catch(error => {
                console.log(error);
            });
        } catch (response) {
            console.log("erro " + response)
            alert("Arquivo indisponível!")
        }
    }

控制台响应表明相册和资产已创建,但是我无法在手机存储中找到相册。

0 个答案:

没有答案