react-native-fs

Download a pdf and save to device (ios and android) in react-native

做~自己de王妃 提交于 2021-01-29 20:23:51
问题 I am pretty new to react-native (app development as such). I want to download and save a pdf file in user's device in react-native? react-native-fs and rn-fetch-blob showed up as popular options. I am using redux-saga in my project and axios to fetch json data. I am able to get a blob object of the pdf file using axios. So, how can i achieve this downloading and saving the file in the device? Can i use axios plus some library to get the file from blob object or should i be using either react

Download a pdf and save to device (ios and android) in react-native

╄→гoц情女王★ 提交于 2021-01-29 16:56:17
问题 I am pretty new to react-native (app development as such). I want to download and save a pdf file in user's device in react-native? react-native-fs and rn-fetch-blob showed up as popular options. I am using redux-saga in my project and axios to fetch json data. I am able to get a blob object of the pdf file using axios. So, how can i achieve this downloading and saving the file in the device? Can i use axios plus some library to get the file from blob object or should i be using either react

Open a file (pdf, word, excel, png etc.) on device with its default application in react-native

此生再无相见时 提交于 2020-12-30 09:46:15
问题 I'm using react-native-fs to download a file(pdf, word, excel, png etc.) and I need to open it in other application. Is it possible to open downloaded file with Linking or better open a dialog with possible apps like when using Sharing? Linking in the code below tries to open the file but it closes immediately without any notification, but my app is still working fine. Is there some special way to build URLs for deep linking for a specific file type? Any ideas for the best solution? I see

How to avoid “Excessive number of pending callbacks: 501” error during images download in React Native?

我与影子孤独终老i 提交于 2020-12-13 04:35:05
问题 I need to download a collection of images on button press. Currently, I'm doing it this way using react-native-fs : const downloadImageItem = async (imgUrl, id) => { const path = `${RNFS.DocumentDirectoryPath}/${id}.jpg`; RNFS.downloadFile({ fromUrl: imgUrl, toFile: path, }); }; const downloadImages = async (items) => { for (const item of items) { if (item.images.length) { await downloadImageItem(item.images[0].thumb, item.images[0].id); } } return Promise.resolve(); }; Calling the function

react native fs library not writing files

半城伤御伤魂 提交于 2020-01-24 06:05:08
问题 when i use react-native-fs to create file, success in callback arrives but the file isn't in my android/data/com.myapp/files/test.txt library. No errors in logcat so i'm wondering why my code with simple App.js not working. /** * Sample React Native App * https://github.com/facebook/react-native * @flow */ import React, { Component } from 'react'; import { Platform, StyleSheet, Text, View, TouchableOpacity, ToastAndroid } from 'react-native'; const instructions = Platform.select({ ios: 'Press

How to read JSON file with React-Native-fs

耗尽温柔 提交于 2019-12-20 05:56:27
问题 I have a asset.json file with content, and need to read it within an react-native app. I already figured that it must be manually copied to the native implementation and I can verify the file is there (and readable: -rw-r--r--). Since its there and I'm using promises to obtain it, please tell me whe the output is still: {"_40":0,"_65":0,"_55":null,"_72":null} and not the content of the file. const path = RNFetchBlob.fs.dirs.DocumentDir + '/' + ASSET_FILENAME; if (await RNFS.exists(path)){

Why RNFS can't write file as a doc file in iOS?

故事扮演 提交于 2019-12-13 02:57:22
问题 I'm trying to open a doc file written using RNFS. But I'm unable to open that file. When I try to open the file using the word application in iOS , I'm getting this error showing "Can't open file, file format doesn't match the file extension". var path = RNFS.DocumentDirectoryPath + "/test.doc"; RNFS.writeFile( path, "Project Details\n", "utf8" ); But this is working fine in android. 回答1: iOS only provides .doc files for read only. You have to use .docx . import { Platform } from 'react

react-native-pdf-view - How to populate pdfView with base64 or blob

最后都变了- 提交于 2019-12-12 14:53:10
问题 I am using the react-native-pdf-view library and I am having trouble populating the PDFView with a pdf. How my project works is that I receive a base64 pdf from the server where I then save to the android file system by using the library react-native-fs like so: (This works fine) saveFile(filename){ var base64Image = this.state.imageBase64; // create a path you want to write to var path = RNFS.DocumentDirectoryPath + '/' + filename; // write the file RNFS.writeFile(path, base64Image, 'base64'

How to search through iPhone filesystem downloads folder for mp3 files in react native

帅比萌擦擦* 提交于 2019-12-12 03:47:23
问题 I'm working on an react native ios app where I want to look through the iPhone's downloads folder for .mp3 files that I can play. I've found a library react-native-fs but right now I am only able to see files added to my app and I can't figure out how to search for .mp3 files already on the iPhone. Any advice on libraries to use or code would be appreciated. Code for my project: https://github.com/Laybium/laybium 回答1: In iOS apps have access only to their sandboxes. There's no such a thing as