https://grokonez.com/android/firebase-storage-upload-file-from-memory-local-stream-android
Firebase Storage – Upload Data from Memory, Local File, Stream | Android
Firebase Cloud Storage helps us upload and share rich content data. Data is stored in a Google Cloud Storage bucket. With Firebase, we can perform robust operations (download/upload) regardless of network quality with strong security (Cloud Storage integrates with Firebase Authentication) and high scalability.
In this tutorial, we're gonna look at ways to upload data from Memory, Local file, Stream in an Android App using Firebase Storage.
More practice:
- Firebase Storage – Download Files to Memory, Local File | Android
- Firebase Storage – Get List of Files example – Image List | Android
I. How to upload file
To use the Firebase Storage to upload data, we need:
- add Firebase to Android App & enable Firebase Auth
- create a reference to the full path of the file, including the file name
- upload data using
putBytes()
for in-memory data,putStream()
for stream data,putFile()
for local file.0. Add Firebase to Android App
0.1 Create Firebase Project and Add Firebase Config file
Follow this guide to create Firebase Project and generate google-services.json file and move it into your Android App root directory. You don't need to get SHA-1 Key in this example.0.2 Add dependencies
-
build.gradle (project-level):
buildscript { // ... dependencies { // ... classpath 'com.google.gms:google-services:3.1.0' } }
-
build.gradle (App-level):
dependencies { // ... compile 'com.google.firebase:firebase-auth:11.0.2' compile 'com.google.firebase:firebase-storage:11.0.2' }
apply plugin: 'com.google.gms.google-services'
1. Enable Firebase Auth
By default, only authenticated users can read or write data, so we need Firebase Authentication for next step.
Go to Your Firebase Project Console -> Authentication -> SIGN-IN METHOD -> Enable Email/Password.
https://grokonez.com/android/firebase-storage-upload-file-from-memory-local-stream-android
Firebase Storage – Upload Data from Memory, Local File, Stream | Android
Top comments (0)