firebase-admin-dotnet icon indicating copy to clipboard operation
firebase-admin-dotnet copied to clipboard

FR: Support Cloud Storage

Open takuya1981 opened this issue 6 years ago • 6 comments

firebase-admin-dotnet does not support Cloud Storage yet. I'd like to contribute for it.

The simple specifications are as follows:

  • Need new class to handle Cloud Storage. Its name is FirebaseAdmin.Cloud.FirebaseStorage as an example.
  • FirebaseStorage instance is managed in FirebaseApp class.
  • FirebaseStorage instance has Google.Cloud.Storage.V1.StorageClient instance.
  • FirebaseStorage instance will return the StorageClient instance associated with the Firebase app.
  • Now the Bucket class is returned in other Java/Python SDK. But the Bucket class in .NET is almost data class. It's not neccesary to be returned(It's my opinion).
  • When calling FirebaseApp.Delete(), StorageClient.Dispose() is called.

I would like to open a pull request about the above if there are no problems.

takuya1981 avatar Jun 10 '19 14:06 takuya1981

Seems like a good addition. Except I wouldn't call the class FirebaseStorage. Perhaps StorageClientHelper or just GoogleCloudStorage.

using FirebaseAdmin.Cloud;
using Google.Cloud.Storage.V1;

StorageClient client = StorageClientHelper.DefaultInstance.GetClient();

hiranya911 avatar Jun 10 '19 17:06 hiranya911

Name is StorageClientHelper, I understand.

StorageClient support custom encryption key like this.

public static StorageClient Create(GoogleCredential credential = null, EncryptionKey encryptionKey = null);

This class should support this function like this.

public static StorageClient GetStorageClient(EncryptionKey encryptionKey = null){}
public static StorageClient GetStorageClient(FirebaseApp app, EncryptionKey encryptionKey = null)

What do you think?

takuya1981 avatar Jun 10 '19 23:06 takuya1981

Hi @takuya1981. Thanks again for thinking about this. I'm not convinced that we should expose custom encryption keys at this stage. We haven't exposed it in other languages. Therefore let's start with just GetStorageClient() for now. Note that GetStorageClient(FirebaseApp) won't be necessary if we attach CloudStorageHelper instance to a FirebaseApp. So we are looking at something like:

public class CloudStorageHelper
   public static CloudStorageHelper DefaultInstance;
   public static CloudStorageHelper GetCloudStorageHelper(FirebaseApp app);
   public StorageClient GetStorageClient();

We can support encryption keys in the future if we want to, but that should be supported across all languages if we do that.

hiranya911 avatar Jun 10 '19 23:06 hiranya911

Correction. We can just expose the StorageClient as a static:

public class CloudStorageHelper
   public static StorageClient GetStorageClient();
   public static StorageClient GetStorageClient(FirebaseApp app);

hiranya911 avatar Jun 10 '19 23:06 hiranya911

I understand that encryption key is not needed at the moment and signature of method.

And I opened draft pull request, draft means that encryption key is still supported, I'll delete it.

takuya1981 avatar Jun 11 '19 00:06 takuya1981

I opened pull request. Please review it.

takuya1981 avatar Jun 11 '19 13:06 takuya1981