Skip to content

CONTENT_DOWNLOAD_MISMATCH with successful file download #709

@taiyokato

Description

@taiyokato

Environment details

  • OS: Windows 10 Pro 1809
  • Node.js version: v10.15.3 LTS
  • npm version: 6.4.1
  • @google-cloud/storage version: 2.5.0

Steps to reproduce

  1. Prepare a bucket with Cloud KMS Customer managed Key encryption. All files are private.
  2. Upload an JPEG image file using:
function UploadFile() {
    storage.bucket("somebucket").upload("somefolder/someimage.jpg", {
        gzip: true,
        destination: "somefolder/someimage.jpg",
    }).then(results => {
        console.log("upload OK");
    })
    .catch(err => {
        console.error("Error: ", err);
    });
}
UploadFile()
// Upload works fine.
  1. Try downloading the img file using:
function DownloadFile() {    
    const file = storage.bucket("somebucket").file("somefolder/someimage.jpg");
    
    file.download({
        destination: "someimage.jpg",
        // validation: false, // Why even disable validation?
    }).then(res => {
        console.log("DL OK");
    }).catch(err => {
        console.error(err); // Throws CONTENT_DOWNLOAD_MISMATCH
    })
}
DownloadFile()
  1. Correct decompressed file is downloaded AND exception is thrown: code=CONTENT_DOWNLOAD_MISMATCH message=The downloaded data did not match the data from the server. To be sure the content is the same, you should download the file again.

I've read through Issue 566, but seems like not a solution.

storage.bucket("somebucket").file("somefolder/someimage.jpg").download({validation: false}); works, but there's no reason to or should disable validation.

To make sure if the hashes are actually a mismatch, I ran a local md5sum check on the downloaded and original image files.

$ md5sum downloaded.jpg original.jpg
a045a2e8e6b8d84aa8a319bcdba05419  downloaded.jpg
a045a2e8e6b8d84aa8a319bcdba05419  original.jpg

Downloaded file is a match to the original file.

BTW, This problem doesn't happen if the image is not gzipped on upload.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the googleapis/nodejs-storage API.externalThis issue is blocked on a bug with the actual product.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions