firebase_storage_web

Creator: coderz1093

Last updated:

Add to Cart

Description:

firebase storage web

firebase_storage_web #
The web implementation of firebase_storage.
Getting Started #
To get started with Firebase Storage, please see the documentation
To learn more about Firebase Storage, please visit the Firebase website
Downloading files with getData() #
When using Reference::getData() in the web platform, your bucket must have the correct CORS configuration, or the security mechanisms in the browser will not let you access the downloaded data, with exceptions similar to:
Access to XMLHttpRequest at 'https://firebasestorage.googleapis.com/v0/b/...example.txt?alt=media&token=1234-4321-1234-4321-12341234' from origin 'http://your-web-app.domain.com:PORT' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
copied to clipboard
browser_client.dart:87 GET https://firebasestorage.googleapis.com/v0/b/...example.txt?alt=media&token=1234-4321-1234-4321-12341234 net::ERR_FAILED
copied to clipboard
or
Error: XMLHttpRequest error.
dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 894:28 get current
packages/http/src/browser_client.dart 84:22 <fn>
copied to clipboard
You need to enable CORS response headers in your Google Cloud Storage Bucket, as described in the following document:

Firebase > Docs > Guides > Download Files on Web.

In the example app, ensure there's a cors.json file:
firebase_storage/example$ cat cors.json
[
{
"origin": ["*"],
"method": ["GET"],
"maxAgeSeconds": 3600
}
]
copied to clipboard
And then, with gsutil:
firebase_storage/example$ gsutil cors set cors.json gs://my-example-bucket.appspot.com
Setting CORS on gs://my-example-bucket.appspot.com/...
copied to clipboard
For much, much more information about CORS in Google Cloud Platform, see:

Storage products > Cloud Storage > Documentation > Configuring cross-origin resource sharing (CORS)

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.