Fireship · @fireship

Multiple Concurrent File Uploads with Firebase Storage + Angular

Uploaded February 20, 2019 · Length 8:44

Multiple Concurrent File Uploads with Firebase Storage + Angular

Summary

Build a drop zone file uploader in Angular that handles multiple concurrent files to Firebase Storage.

  • angular file upload
  • firebase storage upload
  • concurrent file upload
  • angular directive
  • drop zone file uploader

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    [Music]

  2. 0:06

    when I first got started in web

  3. 0:07

    development cloud storage buckets were a

  4. 0:09

    relatively new technology and getting

  5. 0:11

    user generated files uploaded to the

  6. 0:13

    cloud was a major pain point but luckily

  7. 0:15

    today we have firebase which makes this

  8. 0:16

    process much easier but just as flexible

  9. 0:18

    for the developer in today's video

  10. 0:20

    you'll learn how to build a drop zone

  11. 0:21

    style file uploader in angular that can

  12. 0:23

    handle multiple concurrent files to

  13. 0:25

    firebase storage if you're new here like

  14. 0:27

    and subscribe and grab the full source

  15. 0:29

    code from fire ship IO I created a

  16. 0:31

    similar video about a year ago but the

  17. 0:33

    number one request has been a system

  18. 0:34

    that handles multiple files concurrently

  19. 0:36

    so in this demo you can drop as many

  20. 0:38

    files as you want onto the drop zone and

  21. 0:40

    then you can pause or cancel each

  22. 0:41

    individual upload the cool thing is that

  23. 0:43

    firebase will handle all the concurrency

  24. 0:45

    under the hood so you can have your

  25. 0:46

    users drop as many files as you want

  26. 0:48

    here and firebase will choose the best

  27. 0:49

    strategy to get those files uploaded to

  28. 0:51

    the cloud which is based mostly on the

  29. 0:52

    user's network connection and another

  30. 0:54

    thing we'll do is save the download URL

  31. 0:56

    to this file in fire store this makes it

  32. 0:59

    really easy to access the raw file if

  33. 1:00

    you're already using fire store in other

  34. 1:02

    parts of your application now I'm going

  35. 1:04

    to show you how to build the drop zone

  36. 1:06

    from scratch and angular but one thing

  37. 1:07

    you should check out is this custom file

  38. 1:09

    drop element from google chrome labs it

  39. 1:11

    has nothing to do with angular

  40. 1:12

    but because web components are awesome

  41. 1:14

    you can just drop it into your angular

  42. 1:15

    app and start using it so this might be

  43. 1:17

    a good alternative for building your own

  44. 1:18

    custom drop zone let's go ahead and get

  45. 1:20

    started first I'm assuming that you have

  46. 1:22

    an angular app along with angular fire

  47. 1:24

    and firebase installed if we take a look

  48. 1:26

    at the app module you can see I have

  49. 1:27

    angular fire storage and fire store and

  50. 1:30

    if we take a look at the CSS for this

  51. 1:32

    application we have a drop zone class

  52. 1:34

    which is just a flexbox with a border

  53. 1:36

    then we have a hovering class that will

  54. 1:38

    change the border from dash to solid

  55. 1:40

    when the user hovers over the box and

  56. 1:41

    all the other styles come from a

  57. 1:43

    framework called bulma which if you're

  58. 1:44

    not familiar with is a cool alternative

  59. 1:46

    to bootstrap or material the first thing

  60. 1:48

    we'll do is generate a directive that

  61. 1:50

    will be able to turn any div into a drop

  62. 1:52

    zone and by drop zone I just mean an

  63. 1:54

    area that the user can drag and drop

  64. 1:56

    files to and then we can receive those

  65. 1:58

    files as an event in our web application