refFromURL method

  1. @override
Reference refFromURL(
  1. String url
)
override

Returns a new Reference from a given URL.

The url can either be a HTTP or Google Storage URL pointing to an object. If the URL contains a storage bucket which is different to the current FirebaseStorage.bucket, a new FirebaseStorage instance for the Reference will be used instead.

Implementation

@override
Reference refFromURL(String url) {
  assert(url.startsWith('gs://') || url.startsWith('http'),
      "'a url must start with 'gs://' or 'https://'");

  String? path;

  if (url.startsWith('http')) {
    final parts = partsFromHttpUrl(url);

    assert(parts != null,
        "url could not be parsed, ensure it's a valid storage url");

    path = parts!['path'];
  } else {
    path = pathFromGoogleStorageUrl(url);
  }
  return ref(path);
}