Skip to content

jpeiffer/cloud_storage_issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloud_storage_issue

Demonstration repo to show the base64 encoding issue when using the Cloud Storage emulator with the googleapis to upload media.

The issue is that when using the Cloud Storage emulator and uploading via the googleapis package, the content is being stored as base64 preceeded by a newline character. For example, uploading this text:

Hello World!

Results in this being stored in Cloud Storage's emulator:


SGVsbG8gV29ybGQh

Usage

To run the example:

  1. Install the Firebase CLI
  2. Open a terminal window in the root and run: firebase emulators:start
  3. Download a GCP service account JSON file and place it in the root named service_account.json.
    • Alternative: the contents can be placed on the environment variable: FIREBASE_SERVICE_ACCOUNT
  4. Execute: dart test

The tests will...

  1. Upload all the files located in data to Cloud Storage.
  2. Download all the files from Cloud Storage and place them in output.
  3. Verify the contents are the same.
  4. Verify the contents are not base64 encoded.

If the tests pass, all is well. If not, the Cloud Storage issue persists.

Advanced

The repo is set to show the issue with the Cloud Storage emulator when using googleapis, but it can also be used to show the same issue is not present when using the live Cloud Storage APIs.

To test against a live Cloud Storage API, set the following environment variables:

Name Value
FIREBASE_SERVICE_ACCOUNT <service account json>
STORAGE_BUCKET <storage bucket name>
STORAGE_URL https://storage.googleapis.com/

Then just re-run the tests.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages