File Upload using Ant Design and ReactJS | Get Upload Remaining Time and Show in Custom Progress Bar

Поделиться
HTML-код
  • Опубликовано: 31 янв 2023
  • #reactjs #antd #fileupload #codewithaamir
    In this video tutorial I have explained how to upload file using ant design components in react js, get upload remaining time, use custom axios upload api, show custom upload progress bar, show custom upload file list, how to make drag and drop upload component in reactjs.
    This video focuses on
    - How to upload files using ant design components in react js
    - How to get upload remaining time and show on react components
    - How to use custom axios upload api to get progress and time remaining events
    - How to show custom upload progress bar in antd Upload component in react project
    - How to show custom upload file list instead of antd upload default file list
    - How to make drag and drop upload component using antd upload in reactjs
    - How to create a util methods to convert timeInSeconds to proper hours, minutes and seconds
    - How to calculate total time to upload multiple files using ant design Upload UI Components
    - How to use antd space component to adjust the UI in this react tutorial project
    - How to use typography to show different content in antd & react project
    - How to show upload success for file upload app features in react js
    - How to use antd upload to convert into a drag and drop file upload componet
    - How to use axios to make post call to upload a file and get file upload progress events
    - How to extract time to upload a file using axios api integrations in react
    - How to use javascipt reduce function to calculate accumulative time remaining for file uploading
    - How to use customRequest prop in antd Upload component
    - How to use action prop in antd upload component
    - How to use showUploadList to hide the default view of upload list
    - How to save current upload list inside a react state
    For more details on how to validate file before upload like rejecting certain file size, or reject certain file types and other props understanding I have already a video on that at • Ant Design File Upload... please go through that to get familiarity with Antd Upload component.
    If you are new to ant-design, I have already added an intro video on ant-design and overview of its components at • Ant Design UI library ... link, please go through that video to set up the ground for further components implementation.
    For more details on ant-design, please visit its documentation at ant.design/components/upload/
    Happy Coding!

Комментарии • 38

  • @deogenesabejuela7016
    @deogenesabejuela7016 9 месяцев назад +1

    Thank you so much. You saved my day. I already wasted 1 day on this. Your tutorial is perfect for my requirements. Thank you so much and god bless you

  • @s.m.mahmudurrahman3166
    @s.m.mahmudurrahman3166 Год назад +1

    that is a fantastic video tutorial. Great work....❤❤❤. This video tutorial was very needed by me

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Glad it was helpful!
      So nice of you!... ❤.

  • @hakan126
    @hakan126 Год назад

    I am in the office and saw your notification. watching now

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Thank you @hakan ahmet,
      I hope you will love this video tutorial as well.
      Please let me know with you feedback on that.
      So nice of you!... ❤.

  • @n4hnuj
    @n4hnuj 2 месяца назад

    Thanks for the video, curious, how did you set up the backend for taking the file upload? Django? Do you also video for explaining that?

  • @arnaudpoutieu1331
    @arnaudpoutieu1331 Год назад +1

    Good!

  • @user-tg1tl2pt6z
    @user-tg1tl2pt6z Год назад

    hi, I have a question about Item.Meta in ant d's List: is it possible to make the text displayed in the description larger or open the text line spacing?

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Yes, you can always override the styling by making font adjustments as explained in following video
      ruclips.net/video/gpG967lkiJc/видео.html
      Please let me know if that works for you.
      Thank you :) :) :)

  • @abdelmonem88
    @abdelmonem88 Год назад

    Hey bro,
    I really appreciate your valuable content and hard work.
    Recently I have used your videos accompanying my tasks.
    I have question realted to this video topic
    How to validate file size and prevent form from submitting in case the file size exceeded 2 megabytes?

    • @CodeWithAamir
      @CodeWithAamir  Год назад +1

      Thank you. @Abd el monem Mohamed
      I have two separate videos that accomulative can answer your questions, I don't have a specific video to accomplish this, may be in future I will create a one.
      So for checking file size and rejecting the the file upload which exceeds 2 megabytes you can get help from this ruclips.net/video/WwYcXR99j_4/видео.html video I have covered this topic there.
      And secondly to have form prevented from submitting you can add a custom validator as explained in this ruclips.net/video/ajp8hmAKEhM/видео.html video and reject the promise in case the file-size as per above video was greater than 2 megabytes, feel free to save in local state etc.
      so it will be something like below
      IS_SIZE_WITHING_LIMITS
      ? Promise.resolve()
      : Promise.reject("Size exceeds the limit."),
      },
      ]}
      >
      I hope it will help you, please let me know if you need any more help on that.
      Thanks

    • @CodeWithAamir
      @CodeWithAamir  Год назад +1

      All the best bro👍

    • @abdelmonem88
      @abdelmonem88 Год назад +2

      @@CodeWithAamir Thanks Aamir the custom validator works perfectly for my use case
      I'm really appreciate your support and from today consider me one of your fans❤
      Greetings from Egypt

    • @CodeWithAamir
      @CodeWithAamir  Год назад +2

      Wow, it’s great to hear the solution worked👍.
      And thank you so much for all of this love 💕. Stay blessed always 🙏❤️

  • @naveenchary6207
    @naveenchary6207 Год назад

    Great Video Aamir.
    Thank you !
    A question here
    What if we want to start uplaoding the files one after the other on a Start uploading button.
    And while uploading what happens if the file upload has failed for some reason and how to handle this situation.
    Please suggest

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Thank you @Naveen Chary,
      If you want to start uploading one after. the other in a sequence or even want to change the sequence based on any priority etc. then you just need to manipulate the files state accordingly, just update/shuffle etc. the files state so you know which file to process next.
      And to upload the files you just need to have a axios.post call as shown in the video. For the failed files you can get that in catch of axios like
      axios.post(......).catch(error=>{
      //Here you can show the error or even retry it with the same file data
      })
      and you can retry automatically with the same file data or you can show the user an error message or something.
      Because we are using our custom axios upload method so we can handle it as per our needs.
      I hope you got the idea here please let me know if you need any more help on that. Thanks .

    • @naveenchary6207
      @naveenchary6207 Год назад

      Thanks for the Quick response Aamir.
      I have no idea on how to retry automatically.
      And here the files are uploading once we choose the file from local.
      How we can achieve the uploading to the server when user clicks a external.button and then start sending data to API.
      Please help.

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Hi Naveen Chary , to start uploading the video on button click, in the implement of that button click you will call the functions like axios.post() instead of doing right away.
      And for retry you just need to re-call the same function on failure like if the function is
      const uploadFile=(file)=>{
      //Try uploading
      //in case of fail call it again
      uploadFile(file)
      }
      I hope you got the idea of retry, please let me know if you still need any more help on that.
      Thank you Naveen Chary

  • @OThiagoliveira
    @OThiagoliveira 7 месяцев назад

    Great content, keep it up!
    But seems like the progress atritube, on the event, do not exists anymore,
    tryed to replicate your example and the progress bar didn't funcion how it was supose to do

  • @WindowsThemes001
    @WindowsThemes001 6 месяцев назад

    how to send base64 data form API ??

  • @DungLe-rp5vu
    @DungLe-rp5vu Год назад

    Hi Aamir,
    I call function onUploadProgress but it just return
    {
    isTrusted: true
    }
    don't have another props
    pls help me !!

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      I am sorry did not get your problem exactly can you please elaborate a little more thanks

    • @IntercomFPV
      @IntercomFPV Год назад

      @@CodeWithAamir the progress event doesnt return "progress" or "estimated". Where did you get those values from?

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Hi IntercomFPV
      I got these values from axios, can you please confirm you are using the latest version of axios and if still you are not getting these values please let me know we can look into it together via zoom etc. thanks

    • @IntercomFPV
      @IntercomFPV Год назад +1

      @@CodeWithAamir Yes I was using an old version. Thanks! Great tutorial btw!

  • @Ismoil_Sharifov
    @Ismoil_Sharifov Год назад

    how to open that localhost:8000 URL address to except files???

    • @CodeWithAamir
      @CodeWithAamir  Год назад +1

      Hi @Sharifov.
      Just to open the localhost:8000 for accepting the file you can create a sample node/express project and creating just few sample/boilerplate APIs may suffice the simple requirements but to create a full file management system will required the whole backend/Dbs etc.
      very minimal code can look something like
      const express = require("express");
      const app = express();
      const port = 8000;
      const cors = require("cors");
      app.use(
      cors({
      origin: "localhost:3000",
      })
      );
      app.get("/", (req, res) => {
      res.send("Hello World!");
      });
      app.post("/fileUpload", (req, res) => {
      res.sendStatus(200);
      });
      app.listen(port, () => {
      console.log(`Example app listening on port ${port}`);
      });

    • @Ismoil_Sharifov
      @Ismoil_Sharifov 8 месяцев назад

      @@CodeWithAamir thank you bro!

    • @davidechirichella
      @davidechirichella 3 месяца назад

      @@CodeWithAamir And what i have to change when my file will be charged on a hosting space?

  • @panumassaewong8224
    @panumassaewong8224 Год назад

    Next time please let me know for form upload for create and edit data.

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Hi @Panumas Saewong ,
      Thank you for the suggestion, I will try me best to come up with that tutorial as well in my future videos.
      Thanks

    • @CodeWithAamir
      @CodeWithAamir  Год назад +1

      Hi @Panumas Saewong,
      Today I published a video which covers file upload within a form component and shows how to prevent form submit without a file or without certain file size etc.
      ruclips.net/video/2EPfEnNwtWU/видео.html
      I hope that video will be helpful in your use case as well . Please let me know with your feedback on that., Thank you

  • @tusharkhandejod8327
    @tusharkhandejod8327 Год назад

    Hello can u pls add one video on how to extract zip files from frontend using React and javascript?

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Hi @Tushar Khandejod
      I have a video on download different type of files like png, zip etc. using react/javascript at below link,
      ruclips.net/video/IPEqb_AJbAQ/видео.html
      please go through that and let me know if you were looking something like that or need any more information on that. Thanks

    • @tusharkhandejod8327
      @tusharkhandejod8327 Год назад

      @@CodeWithAamir yes i have seen that video but I need a logic where user can upload a zip file and we need to extract the zip file content and upload the extracted content to the backend api in the frontend. So can you please upload one video on that logic as well🙏

    • @CodeWithAamir
      @CodeWithAamir  Год назад

      Hi @Tushar Khandejod,
      I will try me best to come up with that use case video as well if possible. It may be your specific case where you need it on frontend but my recommendation is frontend should not be doing the heavy lifting of extracting the files it may be larger in size and it can slow down the frontend processing. I recommend to upload the zip file to backend and backend should do the heavy extraction etc. work.
      Thanks