How can I stream data from React Native webview to React Native? - javascript

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?

Related

Saving base64 string as an image to the storage

I am developing a React Native application. I have an AWS Amplify backend set up for my up, including the S3 bucket. I am using an ImagePicker package for adding existing photos from the device storage and taking new photos using the device camera. I get a base64 string as a response from the ImagePicker that does the job of showing this string as a normal image on the screen. Now I need to save this image to the S3 bucket and I am not sure what's the right strategy for that. It does save it just as a string in a document but I wonder if there is a way to save it as a real image to the S3 bucket? Like convert base 64 string to an image and upload it to the storage? Or what would be the right approach here?

React native rn-fetch-blob download issue

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

React Native - How to open my application when click on file from local device

I am using React Native and Expo.
I have file with unique extension (For example: SomeFileName.xxx) and it contains some text.
I want when I try to open this file from the device, it will open the application (Android/IOS) and I need read the content of the file.
How can I do that?
It really depends what is the extension of the file!,
And it also depends upon where the file is saved.
Everything is possible in react-native-cli but in Expo it comes with very limited possibilities,
Expo does have a file-system api that allows you to access local files on device!,You can read/write any file to local directories of device!.
Here's the doc for file system:-
https://docs.expo.io/versions/latest/sdk/filesystem/
Thanks!.

Upload and Loading videos in react native

I has being develop video uploading app using react-native.User can record video by in app camera.
Are there any way to reduce file size and/or uploading time also displaying/loading time in react-native or javascript? Are there any help to solve this one in front-end?
Yes, you can optimize file size and also display upload progress. FFmpeg is generally used to manipulate video files. With the help of WebAssembly, you can execute FFMpeg right within the app and manipulate video files. Refer to the GitHub link. [You may have to check if this works with React native]
The idea is to read the blob received from MediaRecorder (available in chrome and firefox, there is also npm package for react native) and pass it to FFMpeg WebAssembly port. Later the optimized bytes can be sliced using Blob and sent to the server (check the slice method in JavaScript Blob).
Recommendation
While you can perform all the above steps right within the client app, it is better to run video optimization utilities in the server rather than within the client app. The right approach to stream the data received from MediaRecorder at regular intervals to the server using either WebSocket or Ajax requests.

React Native download file from server

I want my react app to be able to download (for example) PDF files. But these PDF files should only be downloaded through my react app. If I google around for downloading files with react native all I get is stuff like react-native-fetch-blob and the request looks like this:
.fetch('GET', 'http://www.example.com/file/example.pdf', {
(The example above is part of a bigger piece of code.)
Now if you would visit http://www.example.com/file/example.pdf in your browser you will see the PDF file but I don't want that. I want to make it so that the PDF file can only be downloaded through the app and nowhere else.
How would I go about making a system like this?
Thanks in advance for helping!

Categories

Resources