google-cloud-storage 1.33.0 → 1.34.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6900463b2861e35e33cef3bda84de638f0f9e7d80e8424755f5eef311bd20352
4
- data.tar.gz: 6469082cd9d6b158a71a808874104e20128187c4c611a0fe71dbd80b0f68e54e
3
+ metadata.gz: b25b270d900a20eeef47726ae61ddbaf11457d3cdab25c1d8b2169d4537f0047
4
+ data.tar.gz: 4cdc04bbe927ada1e58ee895889c210d1a3afebfadb7917e8dfd8db7218bcd4b
5
5
  SHA512:
6
- metadata.gz: 4d32314a8813b66cf6ec488be10c8ac174cb71a54d175cff9f33809a529f4851ff2482a43c646f114c91cac4bf7fbc90cc4135caab85d1a55ab8c732f11c1c5f
7
- data.tar.gz: '08382f70eb5759b7ccb98ac0bb793bed114bd3fcc24b6ca8e3ecc02af2e60540f1761d36133d8299b043155d260d9a659ab2d5b0cda6a27eb40ead70d7b7d6d1'
6
+ metadata.gz: 3afb0f705f9592631928e5f4645513b273d729067578f333052e0dc51da38d8aa4951ba2778aaeb3e6799680fa783a2ce6426d6abaf5e9c796029977ce3ecaea
7
+ data.tar.gz: 750da06b028394f5018431945ba86a44733414b334cc9677f81031fd6f0271df47ae74612047487f077ec27c06f645b27b0ab4e6bb875134610c197ac3fd446a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Release History
2
2
 
3
+ ### 1.34.0 / 2021-06-30
4
+
5
+ #### Features
6
+
7
+ * Add support for automatic crc32c and md5 upload verification
8
+ * Add checksum to Bucket#create_file
9
+
3
10
  ### 1.33.0 / 2021-06-29
4
11
 
5
12
  #### Features
@@ -1332,16 +1332,34 @@ module Google
1332
1332
  # changed to a time in the future. If custom_time must be unset, you
1333
1333
  # must either perform a rewrite operation, or upload the data again
1334
1334
  # and create a new file.
1335
+ # @param [Symbol, nil] checksum The type of checksum for the client to
1336
+ # automatically calculate and send with the create request to verify
1337
+ # the integrity of the object. If provided, Cloud Storage will only
1338
+ # create the file if the value calculated by the client matches the
1339
+ # value calculated by the service.
1340
+ #
1341
+ # Acceptable values are:
1342
+ #
1343
+ # * `md5` - Calculate and provide a checksum using the MD5 hash.
1344
+ # * `crc32c` - Calculate and provide a checksum using the CRC32c hash.
1345
+ # * `all` - Calculate and provide checksums for all available verifications.
1346
+ #
1347
+ # Optional. The default is `nil`. Do not provide if also providing a
1348
+ # corresponding `crc32c` or `md5` argument. See
1349
+ # [Validation](https://cloud.google.com/storage/docs/hashes-etags)
1350
+ # for more information.
1335
1351
  # @param [String] crc32c The CRC32c checksum of the file data, as
1336
1352
  # described in [RFC 4960, Appendix
1337
1353
  # B](http://tools.ietf.org/html/rfc4960#appendix-B).
1338
1354
  # If provided, Cloud Storage will only create the file if the value
1339
- # matches the value calculated by the service. See
1355
+ # matches the value calculated by the service. Do not provide if also
1356
+ # providing a `checksum: :crc32c` or `checksum: :all` argument. See
1340
1357
  # [Validation](https://cloud.google.com/storage/docs/hashes-etags)
1341
1358
  # for more information.
1342
1359
  # @param [String] md5 The MD5 hash of the file data. If provided, Cloud
1343
1360
  # Storage will only create the file if the value matches the value
1344
- # calculated by the service. See
1361
+ # calculated by the service. Do not provide if also providing a
1362
+ # `checksum: :md5` or `checksum: :all` argument. See
1345
1363
  # [Validation](https://cloud.google.com/storage/docs/hashes-etags) for
1346
1364
  # more information.
1347
1365
  # @param [Hash] metadata A hash of custom, user-provided web-safe keys
@@ -1473,6 +1491,7 @@ module Google
1473
1491
  content_language: nil,
1474
1492
  content_type: nil,
1475
1493
  custom_time: nil,
1494
+ checksum: nil,
1476
1495
  crc32c: nil,
1477
1496
  md5: nil,
1478
1497
  metadata: nil,
@@ -1490,7 +1509,8 @@ module Google
1490
1509
  path ||= file.path if file.respond_to? :path
1491
1510
  path ||= file if file.is_a? String
1492
1511
  raise ArgumentError, "must provide path" if path.nil?
1493
-
1512
+ crc32c = crc32c_for file, checksum, crc32c
1513
+ md5 = md5_for file, checksum, md5
1494
1514
 
1495
1515
  gapi = service.insert_file name,
1496
1516
  file,
@@ -2821,6 +2841,18 @@ module Google
2821
2841
  raise ArgumentError, "cannot find file #{file}"
2822
2842
  end
2823
2843
 
2844
+ def crc32c_for source, checksum, crc32c
2845
+ return crc32c unless [:crc32c, :all].include? checksum
2846
+ raise ArgumentError, "'checksum: :crc32c' or 'checksum: :all' is present with 'crc32c' arg" if crc32c
2847
+ File::Verifier.crc32c_for source
2848
+ end
2849
+
2850
+ def md5_for source, checksum, md5
2851
+ return md5 unless [:md5, :all].include? checksum
2852
+ raise ArgumentError, "'checksum: :md5' or 'checksum: :all' is present with 'md5' arg" if md5
2853
+ File::Verifier.md5_for source
2854
+ end
2855
+
2824
2856
  ##
2825
2857
  # Yielded to a block to accumulate changes for a patch request.
2826
2858
  class Updater < Bucket
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Storage
19
- VERSION = "1.33.0".freeze
19
+ VERSION = "1.34.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.33.0
4
+ version: 1.34.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-29 00:00:00.000000000 Z
12
+ date: 2021-06-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core