Answer the question
In order to leave comments, you need to log in
Asynchronous file upload?
The user has the opportunity to fill out the form and attach several photos of significant size.
Does it make sense to keep the user waiting for the photo to load, or does it make sense to save the form and download the files in the background?
How are things like this done in Node.js?
Answer the question
In order to leave comments, you need to log in
It depends more on the interface, if the user is on the page only to download files, then it makes sense to keep a modal with progress or the like until the end of the download.
If he definitely does not leave the site (chat, admin panel, etc.), then you can display the progress in the background and in a prominent place.
Example of progress tracking on the front (axios)
const upload = async (files) => {
const config = {
onUploadProgress: (progressEvent) => {
const percentUploaded = Math.round((progressEvent.loaded * 100) / progressEvent.total);
console.log(percentUploaded);
}
}
const data = new FormData();
data.append('file', files[0]);
await axios.put('/api/url', data, config);
}
Does it make sense to keep the user waiting for the photo to load, or does it make sense to save the form and download the files in the background?What are you going to keep? It all depends on the criticality of the data, if the user submits the form and closes the page without waiting for the files to load, you will have crap in terms of data connectivity - the form data is there, but there are no pictures.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question