What is the difference between putFile() and putStream() methods of StorageReference of Firebase cloud storage?

1k views Asked by At

I want to upload files to the Firebase cloud storage. I found that there are two different methods that I can use, which are StorageReference.putFile() and StorageReference.putStream() . I am confused on what is the difference between these two methods.

PS: I do not even know the difference between stream and file.

1

There are 1 answers

3
Alex Mamo On BEST ANSWER

The difference is that these are overloded methods and are using different parameters. There are three flavours of putFile() method:

  1. putFile(Uri uri, StorageMetadata metadata, Uri existingUploadUri)
  2. putFile(Uri uri, StorageMetadata metadata)
  3. putFile(Uri uri)

While putStream() method has only two flavours:

  1. putStream(InputStream stream, StorageMetadata metadata)
  2. putStream(InputStream stream)

All these methods do the same, asynchronously uploads from a content URI to this StorageReference and all three return UploadTask.