Fireship · @fireship
Upload Files from Angular to Firebase Storage
Uploaded April 19, 2017 · Length 4:02
Summary
Implement file uploads with Angular and Firebase Storage using the Firebase web API.
- angular firebase storage
- file uploads angular
- firebase storage upload
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in this episode we're going to implement
- 0:03
file uploads with angular and Firebase
- 0:05
storage file storage is currently UNS
- 0:08
supported in the angular Fire 2 package
- 0:10
but it's still possible to use Firebase
- 0:12
storage by inter interacting directly
- 0:14
with the Firebase web API we're still
- 0:17
going to use angular Fire 2 for saving
- 0:19
information about file uploads to the
- 0:21
real-time database such as the files
- 0:23
name and its URL
- 0:28
location the structure this feature is
- 0:30
very similar to the angular Firebase
- 0:33
crud lesson so make sure to check that
- 0:35
out also it's basically just a form that
- 0:38
accepts files uploads them to a storage
- 0:40
bucket then renders the details to a
- 0:45
list the upload class will be used by
- 0:47
the service notice it has a Constructor
- 0:50
for the file attribute which has a class
- 0:52
type of file this class is built into
- 0:55
JavaScript and it defines files that are
- 0:57
passed via HTML form in
- 1:02
inputs the service needs to upload the
- 1:05
file to file based storage then save the
- 1:07
details about the file to the real-time
- 1:09
database first let's add the necessary
- 1:12
Imports including the Firebase
- 1:16
API here's how the push upload function
- 1:19
Works step by step first establish a
- 1:22
reference to the Firebase storage bucket
- 1:25
second Define the upload task as a
- 1:28
promise to put the file F in
- 1:31
storage third monitor the upload task
- 1:34
event using the on
- 1:36
function and last we'll handle the
- 1:39
events of in progress success and
- 1:45
error when the upload is in progress we
- 1:48
will take a snapshot to get the number
- 1:49
of bytes transferred using some simple
- 1:52
math we convert this to a percentage to
- 1:54
display a progress bar for the end user
- 1:57
when the upload is complete we just do a


