Environment details
- OS: MacOS
- Ruby version:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
- Gem name and version:
google-cloud-storage (1.19.0)
Steps to reproduce
- Enable bucket versioning
- Upload a
.json file
- Get the generation number for it
- Upload a new
.json which replaces the previous file
- Attempt to download the previous file
Code example
data = JSON.pretty_generate({ "name" => "Roger" })
# => "{\n \"name\": \"Roger\"\n}"
# generate brand new file
bucket.create_file(StringIO.new(data), "test_1.json")
=> #<Google::Cloud::Storage::File: ... >
prev_generation = bucket.file("test_1.json").generation
# => 1564749365636895
# update the data with different infromation
data = JSON.pretty_generate({ "name" => "Ozzie" })
# => "{\n \"name\": \"Ozzie\"\n}"
# upload to the same location, forcing a new version
bucket.create_file(StringIO.new(data), "test_1.json")
# => #<Google::Cloud::Storage::File: ... >
# parsing from the current file works fine
current_file = bucket.file("test_1.json").download
JSON.parse(current_file.read)
# => {"name"=>"Ozzie"}
# parsing the previous file does not
prev_file = bucket.file("test_1.json", generation: prev_generation).download
# Google::Cloud::Storage::FileVerificationError: The downloaded file failed MD5 verification.
# from ruby/2.5.5/gems/google-cloud-storage-1.19.0/lib/google/cloud/storage/file/verifier.rb:34:in `verify_md5!'
Full backtrace
Google::Cloud::Storage::FileVerificationError: The downloaded file failed MD5 verification.
from /Users/ozziekirkbu/.gem/ruby/2.5.5/gems/google-cloud-storage-1.19.0/lib/google/cloud/storage/file/verifier.rb:34:in `verify_md5!'
Notes
- Copying the older generation file from
gsutil works fine.
- Might be related to the download method. It doesn't seem to include the generation number when downloading the file.
Environment details
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]google-cloud-storage (1.19.0)Steps to reproduce
.jsonfile.jsonwhich replaces the previous fileCode example
Full backtrace
Google::Cloud::Storage::FileVerificationError: The downloaded file failed MD5 verification. from /Users/ozziekirkbu/.gem/ruby/2.5.5/gems/google-cloud-storage-1.19.0/lib/google/cloud/storage/file/verifier.rb:34:in `verify_md5!'Notes
gsutilworks fine.