A non-official Firebase RESTful Storage Client for the Unity Game Engine.
Based on FirebaseStorage.net
All copyrights, trademarks, logos, and assets are the property of their respective owners.
Name: OpenUPM
URL: https://package.openupm.com
Scope(s):
com.rest.firebase
com.utilities
My Registries
Firebase.Storage
packagehttps://github.com/RageAgainstThePixel/com.rest.firebase.storage.git#upm
Note: this repo has dependencies on other repositories! You are responsible for adding these on your own.
// Create a firebase authentication client
var firebaseClient = new FirebaseAuthenticationClient();
// Create a firebase storage client
var firebaseStorageClient = new FirebaseStorageClient(firebaseClient);
// Sign the user in
await firebaseClient.SignInWithEmailAndPasswordAsync(email, password);
// Get a reference to the resource using a path.
var resource = firebaseStorageClient.Resource("root/test.json");
var json = "{\"value\":\"42\"}";
string downloadUrl;
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(json)))
{
// Upload content to storage
downloadUrl = await resource.UploadAsync(stream, new Progress<FirebaseStorageProgress>(progress => Debug.Log(progress.Percentage)));
}
// Get content public download url (doesn't require authentication)
var knownUrl = await resource.GetDownloadUrlAsync();
Assert.IsTrue(downloadUrl == knownUrl);
// Download content
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(knownUrl);
var responseData = await response.Content.ReadAsStringAsync();
Assert.IsTrue(responseData == json);
// Delete storage content
await resource.DeleteAsync();