react native uploading multiple large files(+40) best practices - reactjs

this is a little bit generic question regarding best practices regarding uploading multiple files
so i am making app where user can upload 40+ image at once
since it can be done with fetch or axios but i am afraid of performance issues
like to put to much pressure on js since it is single threaded or causing a crash because of ram usage
what would be the best approach to this like
1-trying to zip the files then upload
2-multi uploading at once
3-uploading one by one
4-other suggestions

Best practice is to upload images in background thread and show upload progress in notification trey. try this library for upload https://github.com/Vydia/react-native-background-upload#readme.

Related

Implementing a upload queue system in ReactJS/NextJS with WebWorkers

I'm working on a platform where user can create rooms, join them and share content. One of major features that needs to be implemented is a robust media upload system, and I have a pretty good idea of how i'm going to achieve this on the backend with chunk-based file upload. An average size for content that users will be uploading would be something like 200MB
On the frontend, I'm using NextJS and the idea is to have a webworker to handle all media upload logic and a queue system to not get affected by components re-rendering and not have to wait on dialogbox until the process completes and continue in the background Is this approach going to work and is it a good practice? Is it going to scale and not have to be redesigned in the long run ? If Yes, do you know any example of it? If not why and what is your suggestion?
Link to an Image explaining what I'm trying to achieve

Firebase cloud functions compress video

I have successfully implemented video sharing in my app using react native and firebase, but I want to ensure videos being stored are no more than 1080x1080 (maybe 720 depending how it looks).
Videos are max 8 seconds long, I am trying my best to keep them under 5MB each if possible. I was able to do some compressing on the client side (crop to square/trim), but I am hoping to be able to compress the videos even more without losing that quality via cloud functions (storage trigger).
After doing some looking around, it looks like Moviepy is a good option, but it use's python and I am not sure how I can use this script inside of a cloud function storage trigger.
Here is what that looks like:
//Not sure how this will import
import moviepy.editor as mp
//Can I get the video here from the bucket path in a cloud function?
clip = mp.VideoFileClip("video-stored.mp4")
clip_resized = clip.resize(height=1080) # make the height 1080px ( According to moviePy documenation The width is then computed so that the width/height ratio is conserved.)
//resize video, then we need to store it in the same location (same file path)
clip_resized.write_videofile("video-stored-resized.mp4")
I would love to hear some suggestions regarding video compressing via a cloud function and thoughts on using the above script/module with cloud functions.
At this point, firebase functions does not support languages other than node.js.
Thus, there are 2 solutions.
if you would like to keep using moviepy.
Writing a part to call moviepy-related apis when firebase storage is triggered in node.js and having the python api in any preferred environments. (I guess you should use pubsub provided by gcp to call the python apis)
writing all parts in node.js
There is a great module called fluent-ffmepg in node.js too but I know adding a watermark with the module is not as easy as moviepy is...
By the way, when I tried to combine vids in firebase functions, I was not able to make it maybe because of the limitation of the environment.
So, I personally recommend the very first solution: ofc it depends on your situation such as how big your video files are.

Streaming a Growing Log File To Browser (DRF/Angular)

I am using Django Rest Framework/AngularJs for developing a web application.
I have a use case in which server needs to stream the contents of a file in realtime, the file itself is growing since some other application is logging in to it. I know many inefficient ways to do this.
Can you suggest some better ways to achieve this. The Django "view" function should not return till the file is growing but still be able to send the incremental data to the client.
Any help will be appreciated.

Medium to large file uploads with progress updates in AspNet Core

By medium to large I mean anything from 10mb -> 200mb (sound files if that is important)
basically I want to make an API that does some spectral analysis on the file itself, this would require a file upload. But for UI/UX reasons it would be nice to have a progress bar for the upload process. What are the common architectures for achieving this interaction.
The client application uploading the file will be a javascript client (reactjs/redux) and the API is written in ASP.NET Core. I have seen some examples which use websockets to update the client on progress, and other examples where the client polls for status updates given a resource url to query the status. Are there any best practices (or the "modern way of doing this") for doing such a thing that I should know of? TIA
In general, you just need to save progress status while reading the input stream in your controller to some variable (session-specific variable, because there might be a few file uploading sessions at the same time) and then get this status from the client-side by ajax requests (or signalr).
You could take a look at this example: https://github.com/DmitrySikorsky/AspNetCoreUploadingProgress
I have tried 11 MB files with no problems. There is line
await Task.Delay(10); // It is only to make the process slower
there, don't forget to remove it in the real solution.
In this sample files are loaded by the ajax, so I didn't try really large files, but you can use iframe solution from this sample:
https://github.com/DmitrySikorsky/AspNetCoreFileUploading
The other part will be almost the same.
Hope this helps you. Feel free to ask if have any additional questions.

Is there anyway to improve the Javascript Built Apps's web page loading time?

I found the first web page loading time for CN1 Javascript Built taking too long, need about 2 minutes.
I attached the Chrome's network loading screen shot, found the classes.js is the most heavy page, possible to zip it?
Second, there is 2 theme files that downloaded sequentially, is it possible for them to load at the same time?
Kindly advice.
Normally I would answer that you can look at the performance section of the developer guide but the relevant sections there relate to reducing the theme.res size which seems pretty small in your case.
The largest portion in your code is the class files so I'm guessing that the best way to reduce them is to further reduce dependencies so the obfucator can remove more dead code. Keep in mind that the classes.js file is cached and can be deployed via CDN's such as cloudflair to improve download speeds. It can be served in a gzipped form as well which is a part of the CDN repertoire.

Resources