I can't believe I found someone who not only uses the same front end stack I do, but uploads super useful videos and explains them with so much clarity. This channel is a gem. Thanks so much
You touch the crucial parts of daily works of me as a front-end developer, in your every single videos. I'm learning so much from you Bruno, thank you.
Amazing video! This was indeed really helpful. Appreciate it! PS: I really laughed at those special 17 seconds where the computer froze XD, used to happen to me sometimes when sharing my screen in an online meeting haha
Omg Bruno, this video is gold. In this hour of video every little part of it is priceless. I have to implement something similar so many many thanks for having uploaded this tutorial. I'm sure it will take me several days to implement what you have done in only 1 hour. But it will be worthy. You're the best teacher ever.
I'd like to ask you only one thing. After having successfully uploaded any of those files to the cloud storage service, but just before submitting the form, image that the form is cancelled, the user close the window or whatever, how do you manage the file that is now "orphan" in the cloud? Maybe keep a log of those files in the database and delete them with a recurring task or something?
Thank you very very much 😊 Regarding your question, it depends on what you are using and how your application is working. If you keep in your database a reference to all the uploaded photos, then it's an easy task to clean the orphan ones, doing a few selects and doing the request to delete in your image provider. If not, you'll basically have to do something, which depending on the size and price of your image could provider can become expensive, getting all the photos metadata and then verify if you have references in your database for them, if not, delete
Thank you for your answer Bruno. I'm actually using Firebase Storage and uploading mp3s so it can get pricey indeed if the precautions are not properly managed. I was thinking about doing the upload of the file at the time as the form is submitted for this reason, but the fact that the file can be uploaded while the user is filling up the rest of the form is a very practical feature. I've just finished testing the upload and it was super easy and it seemed magic thanks to your help. Now I will have to deal with this. Firstly I will code manually the deletion of the file in the onDelete event of the file and in the cleanup of the form when it closes and if it hasn't been submitted. We'll see how do I do the second part. Not sure how and when to program the automated deletions of the orphan files.
😍😍 I always try to zoom stuff. I'm really happy you noticed that 😍😍 I'm probably a weirdo here, but I watch a lot of coding content on my mobile phone. When people don't use proper font-sizes/zoom, it becomes very very hard to follow 🤐 That's the main reason I try to use font-sizes and enough zoom to be "watchable" on mobile phones. That way, people like me can watch code on their mobile phones 😀😀
Thank you Bruno for the great video. Finally I have created what I wanted for so long. All credit goes to you. It took one and half days for me to complete your tutorial, and it was also quite a bit challenging for me because I have no idea how to work with TypeScript. But finally I have done it without TypeScript, and it is working like yours. Thank you very much and keep uploading videos like this.
I'm soo happy to read your comment 😍😍😍 Thank you very much Saif 😍 if you ever have doubts on how to convert some code from typescript to javascript you can use the typescript playground to convert into javascript 😊 I'll paste an example in the next comment 😀
This is an example from my Multi-step Form Tutorial: tsplay.dev/oN5A9N When you open that page, on the left side you have the TypeScript code. After about 5 seconds (more or less), on the right side will appear the JavaScript code :) You can put any TypeScript code on the left, and the TypeScript playground will show on the right the resulting JavaScript code 😀
@@BrunoAntunesPT Thank you once again bruno for the solution, can you tell me something about deleting files from cloudinary. Because I want to create a file CRUD application, and cant find any solution regarding this.
In this video we used the post method to create them. To delete them we need to use the delete method: cloudinary.com/documentation/admin_api#resources
@@BrunoAntunesPT Hi Bruno yes, I have visited the API documentations before, and also some other sites like github and stackoverflow. But very sadly to say I havn't found any effective solutions for react. Some people are saying that, Accessing Cloudinary Admin panel is not possible from client site like react, because of security issues. Cloudinary also has solutions but just for node and other backend platforms. cloudinary.com/documentation/admin_api There is no clear expiations for react or any other client site platform. Though it has some documentation for react, but it is just for image and video transformation. I dont know what to do. 😭😭😭
In nextjs you can't change the public folder at runtime 🙂 From their docs: Note: Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third party service like AWS S3 for persistent file storage. nextjs.org/docs/basic-features/static-file-serving
@@BrunoAntunesPT I'm using react for displaying a list of files from an api and using react-dropzone to upload files to S3 bucket but not sure when and how should I update the list of already existing files. I'm storing the list of files in redux store and display it on the useEffect of FileUpload component.
@@mihailshahov9481 I fetched the files from the server on useEffect and stored the files in a useState variable files. Updated the files array on useEffect with files as dependency
Bruno, I would love if you could make a video about productivity with vscode, indicating the good extensions and operations (for instance, I don't know how you do auto-imports so practically). As this video will soon be out of date, according to the speed that new extensions come in, in the text part you could simply complement it with the news after the release of the video. I see that you are extremely careful and kind to your followers and I think this initiative will be so appreciated by your followers. Even if you don't do that I thank you for analyzing.
Yes and no 😅 Now a bit more serious: yes! But if you delete on the front end only, then what will happen when your users leave the page? Or their computer crashed after upload? Or they lose connection? Your they get bothered and leave? You'll end up with tons of files in cloudinary. And believe me, that happens a lot in production apps 😅 Short answer: I have batches doing cleanup in the backend so I don't need to worry on the front end 🙂
Thank you David, I'm happy it helped you 😍 I'm Portuguese - Lisbon, but I'm living in London - England 😅😅 Looking at your name I guess you are Portuguese or from a Portuguese speaking country, am I right? 😍😍
Eu consigo ver que fizeste um comentário mas não consigo ler, o RUclips apagou 😔 Isso normalmente acontece quando tem um URL para algum site, foi esse o caso?? 😅😅😅
@@BrunoAntunesPT Não, no comentário eu apenas disse que sou do Brasil e que imaginei que você também falasse português, por conta do seu nome, que é parecido com meu nome do meio. Muito estranho o RUclips ter removido esse comentário hahaha
Ah Brasil 😍😍😍 fico muito feliz por saber que eh um irmão 😍😍 Muitas das vezes não percebo pq o RUclips apaga o comentário, mas apaga cerca de 2 ou 3 comentários por semana 😔😔
Wow great video! But if I download the source code and open it in VS code I get error messages that the material ui packages/elements cannot be found.... What do I have to do to fix this?
Great video - you are a good teacher , you may consider putting a preview of the image , and delete deletes the preview before upload - and also a feature to delete the picture in cloudinary - that would be good - how to put picture in separate folder in cloudinary it is going to root top level?
I actually thought about recording those things as part of this video, but it was already close to 1 hour, so I ended up removing it from the video =D It's something that I can record again in the future and release if you find interesting :)
Thanks so much for the tutorial. I have a question and hope that somebody could help me. Why do my dropzone uploaded files disappear when I change pages with a multiStep?
Thank you 😊 Without code is impossible to give you an accurate reason why that happens, but my feeling is that you are destroying the component with some if else logic to render or not render the steps 😊 When you go back to that step you recreate the component to show it, and of course the state is started from fresh because the component is a completely new instance 😊 But if you have your github at hand, I can have a look and double check if my suspicions are correct 😅😅
Hi Bruno. Thanks for the awesome tutorial 🙂 Learned enough to build a file picker for the task at hand in my job. I have one question - when you delete a file, is it not still being uploaded? The component is only removing from the files state, and hence progress bar (FileHeader) disappears. I guess if the upload is in progress, we need to cancel the request. Is that he right thing to do? Also, what should we do if the image has already been uploaded and we need to delete? Appreciate any pointers on this.
Hey, Thanks for the tutorial. I have everything setup and working on localhost but when I deploy to prod I get this error: Type error: Cannot find module 'react-dropzone' or its corresponding type declarations. Do you know why?
Mine deployed correctly into vercel without any issues - youtube-2021-feb-multiple-file-upload-formik.vercel.app/ Double check my repository to make sure you didn't put a dependency as devdependency or something like that 🙂
Thanks Bruno for your lovely videos, you are the best my dear brother. I dropped 5 files, the progress bar is showing progress for all the 5 files simultaneously. Should progress bar not activate synchronously showing progression of each file to 100% completion then showing progression for the next file to 100% completion, and so forth?
Thank you very much 😀😀 We are uploading the files in parallel. If you drop 5 files (for example) we try to upload the 5 of them in parallel to be much much faster 😊 if one of your files is much bigger than the others you'll see the bars are independent of each other, and the bigger file will complete after the others 😉
Sir, i have a question . If anyone change the extension and upload it to the server. In that case how to validate that file before uploading... Eg. Suppose I have a file virus .zip , now I change it to virus.png and upload it to the server.. then how to protect the server from this kind of hoax image through validation...
@Bruno Antunes could you please tell how you are getting the auto import drop-downs in VS code at 8:56 and 5:56? Is this some VS Code extension? Please help me in enabling this.
The only extension I use on vscode for the videos is Prettier. Other than that I don't use any other extension in my videos to avoid confusion 😅😊 The way you can import is by having your cursor positioned on the "error". After your cursor is positioned correctly, press and holding "control" key, then press the "." key - while still pressing the "control" key 😊 Doing that it will open what you saw 😊
If you are learning vscode, this is very very very useful. I still have this printed on my desk 😅😅 code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
I can see you did 2 comments with URLs, but RUclips deleted them =( If you had URLs pointing to binaries, usually RUclips blocks them... can you share your GitHub URL? In the meantime, if you want, you can clone my GitHub repository to see the differences between mine and yours :)
Great explanatory video - I enjoyed it and learned a ton. Wish formik wasn't involved as I never used it and can't get to understand the part with useEffect and setting value via helpers. Maybe just need some more time to get a grasp of it :)
The part where you handled the progress, cant that be handled using axios as you mentioned, Is it more complex to do in axios than the displayed method?
I can't understand or visualize what you mean. Do you have a real application I can look at (like Gmail or Facebook or LinkedIn something like that)? 🙂
Thank youuuu =D You can do something like this: codesandbox.io/s/headless-hill-09y41?file=/src/pages/index.tsx That's just a "hacky" way I did, let me know if that is what you were looking for :)
@@BrunoAntunesPT I received a warning eslint on MultipleFileUploadField.tsx. can you help with this please? I should not use // eslint-disable-next-line react-hooks/exhaustive-deps ------ const files: UploadableFile[] React Hook useEffect has a missing dependency: 'helpers'. Either include it or remove the dependency array.eslint useEffect(() => { helpers.setValue(files) }, [files]) If I add the helpers to the array of dependencies in the useEffect, it will come with the page with infinite loop
Great video, thanks! I'm getting a linter complaint I don't quite understand though, could you explain it? It's in SingleFileUploadWithProgress.tsx: useEffect(() => { async function upload() { const url = await uploadFile(file, setProgress); onUpload(file, url); } upload(); }, []); I get this warning: "React Hook useEffect has missing dependencies: 'file' and 'onUpload'. Either include them or remove the dependency array." Adding them to the array like ESlint wants just makes the upload continue in an endless loop. It works if I leave them out.
Yes, basically eslint is warning that you are using a dependency inside your effect that is not declared in the dependency array - this is on purpose, so you can add this line before "}, []);": // eslint-disable-next-line react-hooks/exhaustive-deps
If by insta you mean Instagram I don't use Instagram 😅 if you meant the GitHub URL you can find it over here: github.com/bmvantunes/youtube-2020-june-multi-step-form-formik
How can we cancel an ongoing file upload, so that everything (other methods, promises etc.) is stopped/rejected. We are currcently dealing with the problem to stop a hash calculation and reject the individual promise after canceling an upload.
Hi Bruno, one question if I may. When connecting formik to our fileupload component with the useEffect hook, react throws at me warning about missing dependecy: helpers. Any suggestion how to work it out ? Thanks in advance!
What you are seeing is most probably eslint, not react 🙂 the eslint rule is called react-hooks/exhaustive-deps You can find more over here: reactjs.org/docs/hooks-rules.html Just add the helpers to the array of dependencies in the useEffect. Optionally you can also add a comment to ignore the rule for that line 🙂 I hope this helps 🙂
@@BrunoAntunesPT Thank you very much for such a prompt reply, I will check the react docs! Btw. love your content and the way you can explain your code :) ... Just wanted to mention that I even tried to include the helpers object inside the dependency array and the whole app got stuck in an infinite loop as if the helpers object returned from the useField hook was constantly changing? Or is it some sort of reference problem between the upload component and the useField hook itself?
Thank you ❤️ It's possible they (formik) return a new object every time we call their hook 😅😅😅 When you are 100% sure you don't care about a dependency, you can use the comment to ignore that line 🙂
To do that, you'll need to add a new value into the field array for the description 😊 I have a video explaining field arrays in formik 😊 ruclips.net/video/me1kY_uFe5k/видео.html
12:12 Hello Bruno, do you know of any open source software that has these functionalities (api for file storage) that could be installed on a HDD VPS with large storage size?
@@BrunoAntunesPT Thank you bruno, I can see that those prices are really good. The reason is because the starting point would be around 200GB, and it probably would grow a lot as users can upload images/audio/video, just in case I don't get a huge bill.
Uhmm yeah... it depends on the size of data you need of course 😊 Our biggest app currently has around 10 or 12TB, if I'm not mistaken. We pay something like 200 dollars a month for that. I would say, its worth it's price for us. If we had to manage everything ourself, like backups etc, it would cost us more, but each case and situation is different 😊
@@BrunoAntunesPT That's a good point, but I think that for me what would make it more expensive is the data transfer, (0.09$ per GB per Month). I'll have to give it a try anyway.
@@jrs_devs @Jorge Ramirez Sandin I guess that even if you build your own server for images, you'll probably still use a cdn for performance reasons, so in the end, that's probably a very small difference in price regarding data transfer, because you also pay for the cdn 😊
Bruno, there is an infinite loop creating singleFileUploadWithProgress. Once I change limit file size to 1000kb, it start to show infinite progress bar, so I console log to check re-rendering of that component, and indeed it is. Will check out the master branch and test it Please correct me if I am wrong
To be honest, I don't remember seeing an infinite loop in mine and I tested it with 60MB video files at the time - that being said, a bug in software is always possible 😂😂 Clone mine and re-do your tests there. If it happens there as well, let me know exactly your step by step and I can have a look 🙂
[To help the algorithm xD]: Thank you for your answer about deleting the files on the cloudinary cloud. So, you do the cleanup in the backend using a batch, the logic behind may be something like this? correct me if I am wrong please: When user deletes a image on the front end , you just update the "status" property of the image as deleted, and at the end of the day your batch just takes all image urls with "deleted" status and runs a delete in the cloudinary cloud one by one. Is that right ? Thank you ❤️❤️
Ahhahah thank you 🙂 Regarding the "algorithm" you choose it's very dependent in your application and requirements and country rules 😅 When I upload usually I upload to a folder with the day in the name "yyyy-mm-dd". That way uploads are split by day - and this is useful later (stay with me) 🙂 In my application we have to legally verify and validate all attachments users sent and sign them, so we just validate them and upload them again into a final folder (not the initial temp day folders) - because we do that, every day at night we have a script that deletes the temp folders that are at least 2 days old and that's easy because the folders have the name in them 🙂 keep in mind that depending on the cloud providers some support just move of files from a folder to another for free. Some other platforms force you to delete a file and upload again in the new folder - which can be costly to you and your company if they charge by operation 🙂
Of course, I'm always asking for suggestions 😍😍 What do you mean by variants? I'll give an example let me know if this is what you meant. Example: You go to Nike or Adidas website to buy a t-shirt and each t-shirt has a size (small, medium, large). You buy a pair of shoes and it has size for the shoes. Is that the variants you are referring to? Sorry if I completely misunderstood your request 😅😅
@@BrunoAntunesPT that is it exactly!! it would help me (and i am sure others) out as lot....everywhere i look, e-commerce tutorials in react etc are for single items only..iphone, ipad etc....
I might prepare one for the future. But because it's not something I can prepare in a short period of time let me see if I can help you in the meantime 😊 What specific part are you "struggling" with currently? The act of storing those "variants" in the shopping cart itself? Or showing the multiple "variants" of the "product" in the product/search page? 😊 (it can be also be something else 😊)
@@BrunoAntunesPT const addToCartHandler = () => { props.history.push(`/cart/${productId}?qty=${qty}?size=${size}`); so i am using this to add the "qty" and "size to the url, i am then parsing the url to add to the cart... however this messes up the cart subtotal.....
@@BrunoAntunesPT It seems pretty complicated.... I need to be be able to add a size and or a color to the cart, however, i may also want to add another size or color... say a t-shirt color black, size small qty 3 & size medium qty 1 and a white color.. etc ...
@@BrunoAntunesPT I’m building an application with multi step form with final step to upload the documents.. have to store the state after each step which can move forward and backward. Do you see a better way to handle state? Pls suggest.
You can achieve it without redux... Actually I have a video with exactly what you describe (Multiple Step forms), where I don't use redux. In that video you can move back and forwards in the steps and the state is there for you between the steps 😊 That video URL is: ruclips.net/video/l3NEC4McW3g/видео.html Let me know, if that's what you need/want (in the first 2 minutes of the video I show the final result - if that's not what you want/need you'll know immediately) 😃
@@BrunoAntunesPT yes my friend. I had seen this video before. I am not using stepper , but maintaining state to keep track of step , which also is used to activate a step or deactivate a step. But now I’m realizing I can have a blend of both to achieve what is needed. Thanks yet again! Will keep you posted on my progress.
Awesome 😀 I'm very happy I was able to help, even if just a little bit 😀😍 Keep me posted on your progress my friend and best of luck developing the new project 😍😀😀
it does track progress in large files and slow networks. Of course if the file is very small and/or your network is very fast it will be 0-100. Try a large image and make chrome simulate a 3G network and you can see progress :)
Nice video but what happens when you have your file list consisting of mixed accepted and rejected uploads? If you delete one of the files above wouldn't that lead to duplicate renders/uploads?
In the example you gave if you delete one file nothing will happen to the others. They will not be uploaded again 😊 In the video description you can find a link to the deployed demo and play with it 😊 if you have any questions or suggestion I'm very happy to hear 😍😍😍
@@BrunoAntunesPT I downloaded your repo and unfortunately the bug I encountered still persists. I made a video of that use case, maybe you can check it out and help me to find a solution to this. drive.google.com/file/d/1q-rLEc8JzlHBKbZvSJjxifmLGWhixYWl/view?usp=drivesdk
Ah that makes sense, I'm using the index as key, so that will happen - github.com/bmvantunes/youtube-2021-feb-multiple-file-upload-formik/blob/dfe4570deb49a012de1a18fe187de605a9935117/src/upload/MultipleFileUploadField.tsx#L74 You need to use a stable key instead of the index in that line. The file name is usually not a good idea because it can be repeated 😊
thank you very awesome tutorial and very usefull. but i would love it more if it not depending on some tird party like cloudinary but we can use our own api instead of it
Thank you 😀😀 Yeah, I understand your point completely. As I explained in the video if you deploy to vercel, netlify, aws lambda, heroku etc, you'll need to use an external storage provider, because their file systems are ephemeral. And nowadays those platforms are where I see most people and companies deploying their applications 😊 A few examples of cloud storage are aws s3, azure blob storage, cloudinary, imgx etc... I decided to use cloudinary because their free demo account 😊😀
@@BrunoAntunesPT thank. yes i understand i am using my own api and i am saving pictures to server local storage but i loved many tips who did you used and tat helped me much
@@BrunoAntunesPT i am using file system (fs) i think it's the easiest way for me because i am sending files data encoded on base64 because in my front end side i am using file reader so that i can show the user his image and just when he confirm i send the data
You can copy any typescript file into the typescript language editor, and it will give you the JavaScript version: www.typescriptlang.org/play?target=99&jsx=1# Let me know if that helps :)
Hello Arun, They serve two different purposes :) Honestly in computer science it's very hard to say A is better than B, because it always depends on the use cases/contexts/scenarios you are comparing the two. Next.js might be better in some scenarios, and Express in other scenarios. If you want to give me your use cases I can go a bit deeper :)
Thank you for the feedback 😀 always good to improve receiving this constructive feedback ❤️ I agree with you, ideally the video would have been shorter, but to pass all the information I wanted I was not able find a way to make it shorter, unless I skipped some parts, but then it goes against your other request 😊 Regarding the starting from scratch the only thing I did was run "npx create-next-app" and add formik 😊 Sadly, making those things in the video would have make the video even longer 😅😅 honestly I never know what to do in those situations 😅
I can't believe I found someone who not only uses the same front end stack I do, but uploads super useful videos and explains them with so much clarity. This channel is a gem. Thanks so much
WOW, I feel wonderful after reading your comment 😍😍 thank you soo much Zeeshan, I am very grateful for your words ❤️❤️ thank you, thank you!!!
You touch the crucial parts of daily works of me as a front-end developer, in your every single videos. I'm learning so much from you Bruno, thank you.
WOOOW, thank you!! I'm very happy that I create content that helps you my friend 😍😍
Came here to like the video. will use the knowledge some other time when needed. ;)
Thank you my friend 😀 hopefully one day it will be helpful 😊😊
Man U deserve million subscribers right now.
Ahah thank you 😅 looks like I need to work more to reach those numbers 😀
I love the way you explain everything. we want more tutorials and project series. you are the best.
Thank you my friend 😍😍
What specific videos would you like to see? 😉😉
@@BrunoAntunesPT React Query
I'm currently using swr but react query is also very very interesting 😊
@@BrunoAntunesPT sounds interesting,
Amazing video! This was indeed really helpful. Appreciate it!
PS: I really laughed at those special 17 seconds where the computer froze XD, used to happen to me sometimes when sharing my screen in an online meeting haha
Nice examples. I would have loved to have seen a polished final result example.
I'm curious. What else would you want to see? 😅
Bruno, your explanation was fantastic, very comprehensive and complete! Thank you for sharing!
Thank you very much Paulo ❤️ muito muito obrigado 😍
Omg Bruno, this video is gold. In this hour of video every little part of it is priceless.
I have to implement something similar so many many thanks for having uploaded this tutorial.
I'm sure it will take me several days to implement what you have done in only 1 hour. But it will be worthy.
You're the best teacher ever.
I'd like to ask you only one thing.
After having successfully uploaded any of those files to the cloud storage service, but just before submitting the form, image that the form is cancelled, the user close the window or whatever, how do you manage the file that is now "orphan" in the cloud?
Maybe keep a log of those files in the database and delete them with a recurring task or something?
Thank you very very much 😊
Regarding your question, it depends on what you are using and how your application is working.
If you keep in your database a reference to all the uploaded photos, then it's an easy task to clean the orphan ones, doing a few selects and doing the request to delete in your image provider.
If not, you'll basically have to do something, which depending on the size and price of your image could provider can become expensive, getting all the photos metadata and then verify if you have references in your database for them, if not, delete
*image cloud provider, not image could provider, sorry 😅
Thank you for your answer Bruno.
I'm actually using Firebase Storage and uploading mp3s so it can get pricey indeed if the precautions are not properly managed.
I was thinking about doing the upload of the file at the time as the form is submitted for this reason, but the fact that the file can be uploaded while the user is filling up the rest of the form is a very practical feature.
I've just finished testing the upload and it was super easy and it seemed magic thanks to your help.
Now I will have to deal with this.
Firstly I will code manually the deletion of the file in the onDelete event of the file and in the cleanup of the form when it closes and if it hasn't been submitted.
We'll see how do I do the second part. Not sure how and when to program the automated deletions of the orphan files.
High quality video. Thank you, king
"I will zoom this for you.." - Thank you Bruno! :)
😍😍 I always try to zoom stuff. I'm really happy you noticed that 😍😍
I'm probably a weirdo here, but I watch a lot of coding content on my mobile phone.
When people don't use proper font-sizes/zoom, it becomes very very hard to follow 🤐
That's the main reason I try to use font-sizes and enough zoom to be "watchable" on mobile phones.
That way, people like me can watch code on their mobile phones 😀😀
Respect from India!
Thank you 😀 love to India ❤️❤️
thank you, man! I spent hours and hours trying to do this before I watch you
I'm soo happy reading that 😍 thank you my friend 😍😍
Your explanation is so easy to understand. I'm so glad that I watched this video, I learned a lot from it. Thank you so much.
Thank you for your words Mhon 😃😀 I'm very happy the video was helpful to you 😍
wow thankyou a lot. I can feel your kindness in this video.
Thank you Bruno for the great video. Finally I have created what I wanted for so long. All credit goes to you. It took one and half days for me to complete your tutorial, and it was also quite a bit challenging for me because I have no idea how to work with TypeScript. But finally I have done it without TypeScript, and it is working like yours. Thank you very much and keep uploading videos like this.
I'm soo happy to read your comment 😍😍😍
Thank you very much Saif 😍
if you ever have doubts on how to convert some code from typescript to javascript you can use the typescript playground to convert into javascript 😊 I'll paste an example in the next comment 😀
This is an example from my Multi-step Form Tutorial: tsplay.dev/oN5A9N
When you open that page, on the left side you have the TypeScript code. After about 5 seconds (more or less), on the right side will appear the JavaScript code :)
You can put any TypeScript code on the left, and the TypeScript playground will show on the right the resulting JavaScript code 😀
@@BrunoAntunesPT Thank you once again bruno for the solution, can you tell me something about deleting files from cloudinary. Because I want to create a file CRUD application, and cant find any solution regarding this.
In this video we used the post method to create them.
To delete them we need to use the delete method: cloudinary.com/documentation/admin_api#resources
@@BrunoAntunesPT
Hi Bruno yes, I have visited the API documentations before, and also some
other sites like github and stackoverflow. But very sadly to say I havn't found any effective solutions for react. Some people are saying that, Accessing Cloudinary Admin panel is not possible from client site like react, because of security issues. Cloudinary also has solutions but just for node and other backend platforms. cloudinary.com/documentation/admin_api
There is no clear expiations for react or any other client site platform.
Though it has some documentation for react, but it is just for image and video transformation.
I dont know what to do. 😭😭😭
Hi Bruno! I love your teaching style and your coding style. I am adopting you as my role model for coding!
I have found your tutorials very helpful. Thank you.
Thank you 😀
Thank you, Bruno. Nice video 😊
Thank you 😍
How can I display already existing files from server and upload new files and update the existing files?
In nextjs you can't change the public folder at runtime 🙂
From their docs:
Note: Only assets that are in the public directory at build time will be served by Next.js. Files added at runtime won't be available. We recommend using a third party service like AWS S3 for persistent file storage.
nextjs.org/docs/basic-features/static-file-serving
@@BrunoAntunesPT I'm using react for displaying a list of files from an api and using react-dropzone to upload files to S3 bucket but not sure when and how should I update the list of already existing files. I'm storing the list of files in redux store and display it on the useEffect of FileUpload component.
@@dhruvpahwa7602 I have the same issue. How did you manage to initially display file from server?
@@mihailshahov9481 I fetched the files from the server on useEffect and stored the files in a useState variable files. Updated the files array on useEffect with files as dependency
sorry bruno.. i wanna ask.. can you explain part of 34:54
why the promise need to declare as string?
I'm new typescript and react..
Bruno, I would love if you could make a video about productivity with vscode, indicating the good extensions and operations (for instance, I don't know how you do auto-imports so practically). As this video will soon be out of date, according to the speed that new extensions come in, in the text part you could simply complement it with the news after the release of the video.
I see that you are extremely careful and kind to your followers and I think this initiative will be so appreciated by your followers. Even if you don't do that I thank you for analyzing.
That is something i can create as a blog post because it's easier to keep up to date than a video. Uhmmm i need to think about it 😅
Thank you for the suggestion Paulo 😊
Great job Bruno ! I really love your vidéo ❤️
Hi Bruno! Thank you for this! When deleting an uploaded file, dont you need to also delete the file from the cloudinary cloud ?
Yes and no 😅
Now a bit more serious: yes! But if you delete on the front end only, then what will happen when your users leave the page? Or their computer crashed after upload? Or they lose connection? Your they get bothered and leave? You'll end up with tons of files in cloudinary. And believe me, that happens a lot in production apps 😅
Short answer: I have batches doing cleanup in the backend so I don't need to worry on the front end 🙂
Great video, saved me. One question, where are you from?
Thank you David, I'm happy it helped you 😍
I'm Portuguese - Lisbon, but I'm living in London - England 😅😅
Looking at your name I guess you are Portuguese or from a Portuguese speaking country, am I right? 😍😍
Eu consigo ver que fizeste um comentário mas não consigo ler, o RUclips apagou 😔
Isso normalmente acontece quando tem um URL para algum site, foi esse o caso?? 😅😅😅
@@BrunoAntunesPT Não, no comentário eu apenas disse que sou do Brasil e que imaginei que você também falasse português, por conta do seu nome, que é parecido com meu nome do meio. Muito estranho o RUclips ter removido esse comentário hahaha
Ah Brasil 😍😍😍 fico muito feliz por saber que eh um irmão 😍😍
Muitas das vezes não percebo pq o RUclips apaga o comentário, mas apaga cerca de 2 ou 3 comentários por semana 😔😔
Thanks, how do I search the filename such as image and previes on web? These files is store at network drive, or D drive folder?
Wow great video!
But if I download the source code and open it in VS code I get error messages that the material ui packages/elements cannot be found....
What do I have to do to fix this?
Did you npm install?
Hey Bruno! Great video! You should make a video some day on testing with jest and react testing library with Next/Material UI :)
Thank you very much Karen 😀😀
It'll come sooner or later something regarding testing 😀😀😀
Great video - you are a good teacher , you may consider putting a preview of the image , and delete deletes the preview before upload - and also a feature to delete the picture in cloudinary - that would be good - how to put picture in separate folder in cloudinary it is going to root top level?
I actually thought about recording those things as part of this video, but it was already close to 1 hour, so I ended up removing it from the video =D
It's something that I can record again in the future and release if you find interesting :)
Thanks so much for the tutorial. I have a question and hope that somebody could help me. Why do my dropzone uploaded files disappear when I change pages with a multiStep?
Thank you 😊
Without code is impossible to give you an accurate reason why that happens, but my feeling is that you are destroying the component with some if else logic to render or not render the steps 😊
When you go back to that step you recreate the component to show it, and of course the state is started from fresh because the component is a completely new instance 😊
But if you have your github at hand, I can have a look and double check if my suspicions are correct 😅😅
Hey Bruno, how do you handle http errors while uploading the file which passes our type and size validations?
Hi Bruno. Thanks for the awesome tutorial 🙂 Learned enough to build a file picker for the task at hand in my job.
I have one question - when you delete a file, is it not still being uploaded? The component is only removing from the files state, and hence progress bar (FileHeader) disappears.
I guess if the upload is in progress, we need to cancel the request. Is that he right thing to do? Also, what should we do if the image has already been uploaded and we need to delete? Appreciate any pointers on this.
Salvou minha vida! Brigadão cara!
Obrigado eu Milton =)
Your videos are awesome
Thank you Luiz 😍😍
Hey, Thanks for the tutorial. I have everything setup and working on localhost but when I deploy to prod I get this error: Type error: Cannot find module 'react-dropzone' or its corresponding type declarations. Do you know why?
Mine deployed correctly into vercel without any issues - youtube-2021-feb-multiple-file-upload-formik.vercel.app/
Double check my repository to make sure you didn't put a dependency as devdependency or something like that 🙂
Hi Sir, Can you please tell if we can add pause functionality also here.
Thanks Bruno for your lovely videos, you are the best my dear brother. I dropped 5 files, the progress bar is showing progress for all the 5 files simultaneously. Should progress bar not activate synchronously showing progression of each file to 100% completion then showing progression for the next file to 100% completion, and so forth?
Thank you very much 😀😀
We are uploading the files in parallel.
If you drop 5 files (for example) we try to upload the 5 of them in parallel to be much much faster 😊
if one of your files is much bigger than the others you'll see the bars are independent of each other, and the bigger file will complete after the others 😉
@@BrunoAntunesPT thank you
Sir, i have a question . If anyone change the extension and upload it to the server. In that case how to validate that file before uploading... Eg. Suppose I have a file virus .zip , now I change it to virus.png and upload it to the server.. then how to protect the server from this kind of hoax image through validation...
@Bruno Antunes could you please tell how you are getting the auto import drop-downs in VS code at 8:56 and 5:56? Is this some VS Code extension? Please help me in enabling this.
The only extension I use on vscode for the videos is Prettier. Other than that I don't use any other extension in my videos to avoid confusion 😅😊
The way you can import is by having your cursor positioned on the "error". After your cursor is positioned correctly, press and holding "control" key, then press the "." key - while still pressing the "control" key 😊
Doing that it will open what you saw 😊
If you are learning vscode, this is very very very useful. I still have this printed on my desk 😅😅 code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
@@BrunoAntunesPT Thanks so much :)
FileError and FileRejection are not found error
I don't know what you mean. Can you elaborate? 😊
I can see you did 2 comments with URLs, but RUclips deleted them =(
If you had URLs pointing to binaries, usually RUclips blocks them... can you share your GitHub URL?
In the meantime, if you want, you can clone my GitHub repository to see the differences between mine and yours :)
It came with react-dropzone package. While I am having typescript errors with setFiles() :D
Great explanatory video - I enjoyed it and learned a ton. Wish formik wasn't involved as I never used it and can't get to understand the part with useEffect and setting value via helpers. Maybe just need some more time to get a grasp of it :)
Great video, thanks!
The part where you handled the progress, cant that be handled using axios as you mentioned,
Is it more complex to do in axios than the displayed method?
It's actually easier in Axios, they have a property called progress :)
Awesome ! it really helped me a lot
Awesome 😍😍
How can I create multiple uploadable areas within the same file and conditionally update the corresponding state? Thanks!
I can't understand or visualize what you mean. Do you have a real application I can look at (like Gmail or Facebook or LinkedIn something like that)? 🙂
Thanks so much, it is very helpful, I only have one question is how to delete the list after clicking the submit a form, spent 2 days but was unlucky.
Thank youuuu =D
You can do something like this: codesandbox.io/s/headless-hill-09y41?file=/src/pages/index.tsx
That's just a "hacky" way I did, let me know if that is what you were looking for :)
@@BrunoAntunesPT you're are a genius. this is what I looking for. Thank you so so much.....
You are very welcome 😊😊😊 I'm happy that is what you were looking for 😍😍
@@BrunoAntunesPT I received a warning eslint on MultipleFileUploadField.tsx. can you help with this please? I should not use // eslint-disable-next-line react-hooks/exhaustive-deps
------
const files: UploadableFile[]
React Hook useEffect has a missing dependency: 'helpers'. Either include it or remove the dependency array.eslint
useEffect(() => {
helpers.setValue(files)
}, [files])
If I add the helpers to the array of dependencies in the useEffect, it will come with the page with infinite loop
Thanks bro, it helped a lot! You're very didatic too!
Splendid as usual
Thank you very much my friend ❤️❤️
Great video, thanks! I'm getting a linter complaint I don't quite understand though, could you explain it?
It's in SingleFileUploadWithProgress.tsx:
useEffect(() => {
async function upload() {
const url = await uploadFile(file, setProgress);
onUpload(file, url);
}
upload();
}, []);
I get this warning:
"React Hook useEffect has missing dependencies: 'file' and 'onUpload'. Either include them or remove the dependency array."
Adding them to the array like ESlint wants just makes the upload continue in an endless loop. It works if I leave them out.
Yes, basically eslint is warning that you are using a dependency inside your effect that is not declared in the dependency array - this is on purpose, so you can add this line before "}, []);":
// eslint-disable-next-line react-hooks/exhaustive-deps
@@BrunoAntunesPT I see, thanks!
hi bro ,how to upload csv file in table?please
bro, are you made multi form step. I want to make website clone of zety resume builder in which use multi step form.
If by insta you mean Instagram I don't use Instagram 😅 if you meant the GitHub URL you can find it over here: github.com/bmvantunes/youtube-2020-june-multi-step-form-formik
@@BrunoAntunesPT bro are you made zety resume builder clone
It's not in my plans to build a clone of that app 🙂
thank you Brunoo
Thank you Mario 😀
Great tutorial! Thank you.
Thank you 😍
How can we cancel an ongoing file upload, so that everything (other methods, promises etc.) is stopped/rejected. We are currcently dealing with the problem to stop a hash calculation and reject the individual promise after canceling an upload.
You need to call abort on the xhr call, like here: developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/abort
Then you also need to reject the promise we create to wrap the xhr call
Hi Bruno, one question if I may. When connecting formik to our fileupload component with the useEffect hook, react throws at me warning about missing dependecy: helpers. Any suggestion how to work it out ? Thanks in advance!
What you are seeing is most probably eslint, not react 🙂 the eslint rule is called react-hooks/exhaustive-deps
You can find more over here: reactjs.org/docs/hooks-rules.html
Just add the helpers to the array of dependencies in the useEffect. Optionally you can also add a comment to ignore the rule for that line 🙂
I hope this helps 🙂
@@BrunoAntunesPT Thank you very much for such a prompt reply, I will check the react docs! Btw. love your content and the way you can explain your code :) ... Just wanted to mention that I even tried to include the helpers object inside the dependency array and the whole app got stuck in an infinite loop as if the helpers object returned from the useField hook was constantly changing? Or is it some sort of reference problem between the upload component and the useField hook itself?
Thank you ❤️
It's possible they (formik) return a new object every time we call their hook 😅😅😅
When you are 100% sure you don't care about a dependency, you can use the comment to ignore that line 🙂
in case of multiple file upload how can take input for each file (like a description of the file, any tags for each file )
To do that, you'll need to add a new value into the field array for the description 😊
I have a video explaining field arrays in formik 😊 ruclips.net/video/me1kY_uFe5k/видео.html
How can I clear all uploaded fileheaders after clicking “Submit” in formik? Great video everything else was really clear and easy to follow
Thank you 🙂 on the formik side you just need to setFieldValue to empty array and you are good.
Thank you. You help me alot :D
Awesome video ++++++ 😃
Hands on!!!! WOO
Thank you =D
@@BrunoAntunesPT Thank you brother!
Do you have any idea for a source of types of cloudinary?
@@alexgaetanopadula4057 what do you mean by source of types?
Is this what you were looking for?? cloudinary.com/documentation/image_transformations#image_format_support
12:12 Hello Bruno, do you know of any open source software that has these functionalities (api for file storage) that could be installed on a HDD VPS with large storage size?
Honestly azure blob storage and aws s3 are soo cheap that I never felt the need to look elsewhere 😅
Any specific reason to avoid those 2? 😊
@@BrunoAntunesPT Thank you bruno, I can see that those prices are really good. The reason is because the starting point would be around 200GB, and it probably would grow a lot as users can upload images/audio/video, just in case I don't get a huge bill.
Uhmm yeah... it depends on the size of data you need of course 😊
Our biggest app currently has around 10 or 12TB, if I'm not mistaken. We pay something like 200 dollars a month for that.
I would say, its worth it's price for us. If we had to manage everything ourself, like backups etc, it would cost us more, but each case and situation is different 😊
@@BrunoAntunesPT That's a good point, but I think that for me what would make it more expensive is the data transfer, (0.09$ per GB per Month). I'll have to give it a try anyway.
@@jrs_devs @Jorge Ramirez Sandin I guess that even if you build your own server for images, you'll probably still use a cdn for performance reasons, so in the end, that's probably a very small difference in price regarding data transfer, because you also pay for the cdn 😊
Bruno, there is an infinite loop creating singleFileUploadWithProgress.
Once I change limit file size to 1000kb, it start to show infinite progress bar, so I console log to check re-rendering of that component, and indeed it is.
Will check out the master branch and test it
Please correct me if I am wrong
To be honest, I don't remember seeing an infinite loop in mine and I tested it with 60MB video files at the time - that being said, a bug in software is always possible 😂😂
Clone mine and re-do your tests there. If it happens there as well, let me know exactly your step by step and I can have a look 🙂
Awesome 👍
Thank you Ranga 😀 I'm glad you enjoyed the video 😀😀
[To help the algorithm xD]:
Thank you for your answer about deleting the files on the cloudinary cloud.
So, you do the cleanup in the backend using a batch, the logic behind may be something like this? correct me if I am wrong please: When user deletes a image on the front end , you just update the "status" property of the image as deleted, and at the end of the day your batch just takes all image urls with "deleted" status and runs a delete in the cloudinary cloud one by one.
Is that right ? Thank you ❤️❤️
Ahhahah thank you 🙂
Regarding the "algorithm" you choose it's very dependent in your application and requirements and country rules 😅
When I upload usually I upload to a folder with the day in the name "yyyy-mm-dd". That way uploads are split by day - and this is useful later (stay with me) 🙂
In my application we have to legally verify and validate all attachments users sent and sign them, so we just validate them and upload them again into a final folder (not the initial temp day folders) - because we do that, every day at night we have a script that deletes the temp folders that are at least 2 days old and that's easy because the folders have the name in them 🙂 keep in mind that depending on the cloud providers some support just move of files from a folder to another for free. Some other platforms force you to delete a file and upload again in the new folder - which can be costly to you and your company if they charge by operation 🙂
is there a way to do it without typescript ? , as i only know reactjs
Yes, copy the code and paste into the typescript playground 🙂 it will give you the JavaScript result of it
how do you handle the .xlxs and .xls file ?
The same way 🙂 just add the extensions you need and it will work 🙂
You are the best...
I'm not, you are Gulten 😍😍❤️ thank you very much for your words my friend 😀
can i request a video on adding variants to a react shopping cart? all the youtube videos show single item products.... thanks
Of course, I'm always asking for suggestions 😍😍
What do you mean by variants? I'll give an example let me know if this is what you meant.
Example: You go to Nike or Adidas website to buy a t-shirt and each t-shirt has a size (small, medium, large). You buy a pair of shoes and it has size for the shoes. Is that the variants you are referring to?
Sorry if I completely misunderstood your request 😅😅
@@BrunoAntunesPT that is it exactly!! it would help me (and i am sure others) out as lot....everywhere i look, e-commerce tutorials in react etc are for single items only..iphone, ipad etc....
I might prepare one for the future. But because it's not something I can prepare in a short period of time let me see if I can help you in the meantime 😊
What specific part are you "struggling" with currently? The act of storing those "variants" in the shopping cart itself? Or showing the multiple "variants" of the "product" in the product/search page? 😊 (it can be also be something else 😊)
@@BrunoAntunesPT const addToCartHandler = () => {
props.history.push(`/cart/${productId}?qty=${qty}?size=${size}`);
so i am using this to add the "qty" and "size to the url, i am then parsing the url to add to the cart... however this messes up the cart subtotal.....
@@BrunoAntunesPT It seems pretty complicated.... I need to be be able to add a size and or a color to the cart, however, i may also want to add another size or color... say a t-shirt color black, size small qty 3 & size medium qty 1 and a white color.. etc ...
I’m marking this , needed for my next project!! I’m hoping this is with redux..
I'm not using redux - this component is only dealing with local state (forms - formik). Why would you use redux here? (Genuine question)
@@BrunoAntunesPT I’m building an application with multi step form with final step to upload the documents.. have to store the state after each step which can move forward and backward. Do you see a better way to handle state? Pls suggest.
You can achieve it without redux... Actually I have a video with exactly what you describe (Multiple Step forms), where I don't use redux. In that video you can move back and forwards in the steps and the state is there for you between the steps 😊
That video URL is: ruclips.net/video/l3NEC4McW3g/видео.html
Let me know, if that's what you need/want (in the first 2 minutes of the video I show the final result - if that's not what you want/need you'll know immediately) 😃
@@BrunoAntunesPT yes my friend. I had seen this video before. I am not using stepper , but maintaining state to keep track of step , which also is used to activate a step or deactivate a step. But now I’m realizing I can have a blend of both to achieve what is needed. Thanks yet again! Will keep you posted on my progress.
Awesome 😀 I'm very happy I was able to help, even if just a little bit 😀😍
Keep me posted on your progress my friend and best of luck developing the new project 😍😀😀
This codes does not actually track progress it's just 0 or 100 right?
it does track progress in large files and slow networks. Of course if the file is very small and/or your network is very fast it will be 0-100. Try a large image and make chrome simulate a 3G network and you can see progress :)
Nice video but what happens when you have your file list consisting of mixed accepted and rejected uploads? If you delete one of the files above wouldn't that lead to duplicate renders/uploads?
In the example you gave if you delete one file nothing will happen to the others. They will not be uploaded again 😊
In the video description you can find a link to the deployed demo and play with it 😊
if you have any questions or suggestion I'm very happy to hear 😍😍😍
@@BrunoAntunesPT oh ok thanks I will try it out later today
Awesome 😍 let me know if you find any bug 😅😅😅
@@BrunoAntunesPT I downloaded your repo and unfortunately the bug I encountered still persists.
I made a video of that use case, maybe you can check it out and help me to find a solution to this.
drive.google.com/file/d/1q-rLEc8JzlHBKbZvSJjxifmLGWhixYWl/view?usp=drivesdk
Ah that makes sense, I'm using the index as key, so that will happen - github.com/bmvantunes/youtube-2021-feb-multiple-file-upload-formik/blob/dfe4570deb49a012de1a18fe187de605a9935117/src/upload/MultipleFileUploadField.tsx#L74
You need to use a stable key instead of the index in that line. The file name is usually not a good idea because it can be repeated 😊
Great videos! Gain a lot. Thanks
Thank you Justin =) Glad you like them!
thank you very awesome tutorial and very usefull. but i would love it more if it not depending on some tird party like cloudinary but we can use our own api instead of it
Thank you 😀😀
Yeah, I understand your point completely. As I explained in the video if you deploy to vercel, netlify, aws lambda, heroku etc, you'll need to use an external storage provider, because their file systems are ephemeral. And nowadays those platforms are where I see most people and companies deploying their applications 😊
A few examples of cloud storage are aws s3, azure blob storage, cloudinary, imgx etc... I decided to use cloudinary because their free demo account 😊😀
@@BrunoAntunesPT thank. yes i understand i am using my own api and i am saving pictures to server local storage but i loved many tips who did you used and tat helped me much
That's amazing to hear, thank you my friend 😍😍
Are you using formidable or multer or something else? (for the api side) 😊
@@BrunoAntunesPT i am using file system (fs) i think it's the easiest way for me because i am sending files data encoded on base64 because in my front end side i am using file reader so that i can show the user his image and just when he confirm i send the data
Anyone tried integrating this into React Final Form?
Please make a video on js version
You can copy any typescript file into the typescript language editor, and it will give you the JavaScript version: www.typescriptlang.org/play?target=99&jsx=1#
Let me know if that helps :)
Could
I upload videos with this?
Yes 😊
Express framework is bast or next.js
Hello Arun,
They serve two different purposes :)
Honestly in computer science it's very hard to say A is better than B, because it always depends on the use cases/contexts/scenarios you are comparing the two. Next.js might be better in some scenarios, and Express in other scenarios.
If you want to give me your use cases I can go a bit deeper :)
@@BrunoAntunesPT thanks
If you have a use case, feel free to connect with me on LinkedIn or twitter (usually I'm much more active on LinkedIn, so I will reply faster 😅😅)
CG Dr
Thx!
😍😍😍
thank u!!!
Thank you too!
can you short help me
👍
Thank you Umar 😀🎉
top!!!!, but you have to change computer : )....change to mac ;)
I actually today use Mac with an M1 pro chip 😅
hi sir
Nice tutorial. It would be nicer if you started from scratch and you had a shorter video
Thank you for the feedback 😀 always good to improve receiving this constructive feedback ❤️
I agree with you, ideally the video would have been shorter, but to pass all the information I wanted I was not able find a way to make it shorter, unless I skipped some parts, but then it goes against your other request 😊
Regarding the starting from scratch the only thing I did was run "npx create-next-app" and add formik 😊
Sadly, making those things in the video would have make the video even longer 😅😅 honestly I never know what to do in those situations 😅
Great job Bruno ! I really love your vidéo ❤️
Thank you 😍