Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundancy between uri and bucket+remotePath ? #8

Open
awhitford opened this issue Jun 7, 2020 · 0 comments
Open

Redundancy between uri and bucket+remotePath ? #8

awhitford opened this issue Jun 7, 2020 · 0 comments

Comments

@awhitford
Copy link
Contributor

Consider the following code:

  Future<FirebaseImageObject> get(String uri, FirebaseImage image) async {
    List<Map> maps = await db.query(
      table,
      columns: null,
      where: 'uri = ?',
      whereArgs: [uri],
    );
    if (maps.length > 0) {
      FirebaseImageObject returnObject =
          new FirebaseImageObject.fromMap(maps.first);
      returnObject.reference = getImageRef(returnObject, image.firebaseApp);
      if (CacheRefreshStrategy.BY_METADATA_DATE == this.cacheRefreshStrategy) {
        checkForUpdate(returnObject, image); // Check for update in background
      }
      return returnObject;
    }
    return null;
  }

  StorageReference getImageRef(
      FirebaseImageObject object, FirebaseApp firebaseApp) {
    FirebaseStorage storage =
        FirebaseStorage(app: firebaseApp, storageBucket: object.bucket);
    return storage.ref().child(object.remotePath);
  }

The code seems to be using bucket and remotePath to rehydrate the uri into a StorageReference. Why not simply call FirebaseStorage.getReferenceFromUrl? (And then you can avoid the redundancy of bucket and remotePath.)

I also see that the code is leveraging the firebaseApp, but is that necessary when you have a fully qualified Uri?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant