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

Set custom metadata correctly for resumable uploads #4278

Merged
merged 19 commits into from
Mar 24, 2022
Merged

Set custom metadata correctly for resumable uploads #4278

merged 19 commits into from
Mar 24, 2022

Conversation

abhis3
Copy link
Contributor

@abhis3 abhis3 commented Mar 9, 2022

Description

  • Fixes a bug where resumable uploads were not honoring and setting user provided metadata on file upload.

    • A lot of our existing unit tests use the multipart path in the code, hence why this case wasn't covered.
  • Fixes a bug where certain metadata fields weren't present in CloudStorageObjectMetadata, making them revert to a default value and hence returning incorrect metadata on the final PUT requests.

  • Fixes a bug where GCS metadataUpdate cloud functions were triggered in incorrect situations

Part of fixes to #3398

Scenarios Tested

Tested functionality on a sample iOS app, code here: https://github.com/abhis3/Storage-Emulator-Issue/blob/main/Storage%20Emulator%20Issue/StorageManager.swift

Testing against prod, we see the expected behavior so it's definitely an emulator issue.

Prior to the change, we see that the set metadata looked something like this (using the above app):

FIRStorageMetadata 0x600000b5ca00: {
    bucket = "ios-sdk-issues.appspot.com";
    contentDisposition = inline;
    contentEncoding = identity;
    contentType = "";
    generation = 1646779748099;
    md5Hash = "i91E7z6la2nMpxdarYKjrw==";
    metageneration = 1;
    name = "Profiles/mh1MOpqFgaMI9Iq7kTB72QmsFbYH.jpg";
    size = 31769;
    timeCreated = "2022-03-08T14:49:08.099Z";
    updated = "2022-03-08T14:49:08.099Z";
}

After the changes, metadata looks similar to:

FIRStorageMetadata 0x600000b5ca00: {
    bucket = "ios-sdk-issues.appspot.com";
    contentDisposition = initialCommit;
    contentEncoding = identity;
    contentType = "image/jpg";
    generation = 1646779748099;
    md5Hash = "i91E7z6la2nMpxdarYKjrw==";
    metageneration = 1;
    name = "Profiles/mh1MOpqFgaMI9Iq7kTB72QmsFbYH.jpg";
    size = 31769;
    timeCreated = "2022-03-08T14:49:08.099Z";
    updated = "2022-03-08T14:49:08.099Z";
}

Note the changes in the contentDisposition and contentType fields.

@tonyjhuang
Copy link
Contributor

synced offline, do you mind rebasing off of #4262 and pulling the md -> metadata rename to a separate PR?

scripts/storage-emulator-integration/tests.ts Outdated Show resolved Hide resolved
scripts/storage-emulator-integration/tests.ts Outdated Show resolved Hide resolved
src/emulator/storage/files.ts Outdated Show resolved Hide resolved
@abhis3 abhis3 force-pushed the abhisunDev branch 2 times, most recently from dc62cac to 74a3e70 Compare March 15, 2022 22:41
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

Successfully merging this pull request may close these issues.

None yet

2 participants