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

[Firebase Storage] getDownloadURL return type #1280

Closed
awhitford opened this issue Oct 19, 2019 · 4 comments
Closed

[Firebase Storage] getDownloadURL return type #1280

awhitford opened this issue Oct 19, 2019 · 4 comments
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: storage type: bug Something isn't working type: documentation Improvements or additions to documentation

Comments

@awhitford
Copy link
Contributor

Why is the return type for getDownloadURL a dynamic instead of a String?

  /// Asynchronously retrieves a long lived download URL with a revokable token.
  /// This can be used to share the file with others, but can be revoked by a
  /// developer in the Firebase Console if desired.
  Future<dynamic> getDownloadURL() async {
    return await FirebaseStorage.channel.invokeMethod<dynamic>(
        "StorageReference#getDownloadUrl", <String, String>{
      'app': _firebaseStorage.app?.name,
      'bucket': _firebaseStorage.storageBucket,
      'path': _pathComponents.join("/"),
    });
  }

In practice, the runtimeType seems to be String. Could it be something else?

@awhitford awhitford added the type: bug Something isn't working label Oct 19, 2019
@iapicca
Copy link

iapicca commented Oct 25, 2019

Hi @awhitford
You might want to check the documentation regarding invokeMethod
Closing, as this isn't an issue with Flutter itself,
if you disagree please write in the comments and I will reopen it
Thank you

@iapicca iapicca closed this as completed Oct 25, 2019
@awhitford
Copy link
Contributor Author

Please reopen. I don't understand why the return type is not well documented.

The implementation would have two tiny changes:

  /// Asynchronously retrieves a long lived download URL with a revokable token.
  /// This can be used to share the file with others, but can be revoked by a
  /// developer in the Firebase Console if desired.
  Future<String> getDownloadURL() async {
    return await FirebaseStorage.channel.invokeMethod<String>(
        "StorageReference#getDownloadUrl", <String, String>{
      'app': _firebaseStorage.app?.name,
      'bucket': _firebaseStorage.storageBucket,
      'path': _pathComponents.join("/"),
    });
  }

Note that the Java API has a return type is a Uri, but the Flutter/Dart API seems to be returning a String. Should it also be returning a Uri?

The Swift API seems to indicate that maybe the return value is either a URL (success) or an Error -- so then wouldn't a Future<String> or Future<Uri> be a fine equivalent?

If dynamic is appropriate because the return type may be String or something else, the developer needs to know to handle it appropriately. Right now, I am assuming that I am getting a String, but I don't like to assume.

@BondarenkoStas BondarenkoStas added type: documentation Improvements or additions to documentation resolution: invalid This doesn't seem right and might not belong here. labels Oct 28, 2019
@awhitford
Copy link
Contributor Author

I appreciate the thumbs up support. This looks like a trivial fix; I'm surprised that this is still outstanding. Is there a way that I can help with a pull request?

@iapicca iapicca removed the resolution: invalid This doesn't seem right and might not belong here. label Feb 21, 2020
@Ehesp Ehesp added plugin: storage impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) labels Apr 23, 2020
@Salakar
Copy link
Member

Salakar commented Apr 1, 2021

On the latest release getDownloadURL does return Future<String>: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_storage/firebase_storage/lib/src/reference.dart#L57

@Salakar Salakar closed this as completed Apr 1, 2021
@firebase firebase locked and limited conversation to collaborators May 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
impact: crowd Affects many people, though not necessarily a specific customer with an assigned label. (P2) plugin: storage type: bug Something isn't working type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants