In react native library rn fetch blob i want to fetch data from api and save. The problem i am facing is that i want to save the file from api only after downloading complete. And if downloading cancelled there is no file to be stored . Is there any solution for this . Thanks all
Related
I would like to save large files to the device disk in React Native. To do this one option is to send the whole file in Base64 using the onMessage, but for large files this is not the best option.
Is there a way to stream the file to be saved from WebView to React Native?
Is there a way to download files attached using Paperclip without using libraries?
My goal is to allow the user to download the file as soon as the file is uploaded and before it is sent to the backend.
I found the way to make it working with file-saver
However, I was wondering if that can be done without the library?
You can use the js-file-download package.
https://www.npmjs.com/package/js-file-download
Here's my situation. I'm making a personal file sharing website that consists of the following:
Vue3 app for the front-end
Net 5.0 API for the back-end
These are running under two different url's
share.domain.tld
api.share.domain.tld
After uploading my result is a url to api.share.domain.tld/{identifier} which returns the file.
Not I want to be able to show the file directly in the browser from share.domain.tld/{identifier} which is where my vue app runs at.
My first solution was to just use a redirect in the router by using beforeEnter and just setting window.location.href which works fine when accessing from the browser, however when the share.domain.tld/{identifier} url is sent on a app like Discord it will not follow the redirect and is unable to show the preview for files.
If I request the file through axios and create the blob for it, how can I use js to load the filedata into the browser as it would when loading the file from a url and let the browser use it's usual handling for it such as showing images or pdfs but downloading other types of files such as zips?
I am referring to this post on react native image upload to server: How to upload Image on server using ReactNative
Other than workaround of calling fetch multiple times for multiple image files upload (looping through the files), I was wondering how to upload multiple of image files by just calling fetch once? Could someone provide a simple example?
Thanks in advance!
I worked on a phonegap application using html5 for a month. I handle offline JSON files using File API.
It seems that the JSON files I store are automatically saved on /mnt/sdcard/.
The problem is, I find myself handling 3 files for each file I want.
1 st the file packaged with my app (js/products.js)
2 nd the remote file that sends me updates (http://website/remote_products.js)
3 rd the local file on sdcard I update with the remote data. (/mnt/sdcard/updated-products.js)
Is it possible to - instead of saving on the sdcard - update my app's assets using File API ?
Or create a new file in my app assets folder ?
(the JSON file packaged with my app. Found in js/products.js)
If yes, how plz ?
thx
Sadly, you cannot modify the files in /android_assets/www with the File API.
See this answer to a slightly different question answered by one of the PhoneGap Android devs: https://stackoverflow.com/a/8966227/878602
"You can't do what you want to do. The files in the assets directory are not technically on the file system so they are not accessible via the File API. This means calling window. resolveLocalFileSystemURI() will not return you a FileEntry."
You might consider to utilize Mott:
https://github.com/imlucas/mott, e.g. http://phonegap.com/blog/2013/04/23/story-behind-exfm/
It seems to be able dynamically version, update and persist update of any local asset.