google-cloud-storage 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/google/cloud/storage.rb +45 -0
- data/lib/google/cloud/storage/file.rb +24 -0
- data/lib/google/cloud/storage/service.rb +1 -2
- data/lib/google/cloud/storage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b2256d0194e6d5fbedc19e638b2b57dab8038a9f93a3019538d2eb56b740c4
|
4
|
+
data.tar.gz: 10f4915478a797f777cb64a1cfafa6b841c0590a89f3c8d5784e153a13b8a885
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d0a5be11ac43e57988db525cad4bf2d006d053a0d69b2ed1c017f71771771017f6e9acc190811b2d575c305971f3ecac736082eac399aff9bea62a9d730cdba
|
7
|
+
data.tar.gz: f412a33c819aace6190dfff910df58fe2708b15f2680c8d2749092b860d980d85156e02ebc97a9f7474de90b2f19e67b6c463acd0012c085465225ad7be3e9be
|
data/lib/google/cloud/storage.rb
CHANGED
@@ -317,6 +317,23 @@ module Google
|
|
317
317
|
# downloaded.read #=> "Hello world!"
|
318
318
|
# ```
|
319
319
|
#
|
320
|
+
# Download a public file with an anonymous, unauthenticated client. Use
|
321
|
+
# `skip_lookup` to avoid errors retrieving non-public bucket and file
|
322
|
+
# metadata.
|
323
|
+
#
|
324
|
+
# ```ruby
|
325
|
+
# require "google/cloud/storage"
|
326
|
+
#
|
327
|
+
# storage = Google::Cloud::Storage.anonymous
|
328
|
+
#
|
329
|
+
# bucket = storage.bucket "public-bucket", skip_lookup: true
|
330
|
+
# file = bucket.file "path/to/public-file.ext", skip_lookup: true
|
331
|
+
#
|
332
|
+
# downloaded = file.download
|
333
|
+
# downloaded.rewind
|
334
|
+
# downloaded.read #=> "Hello world!"
|
335
|
+
# ```
|
336
|
+
#
|
320
337
|
# ## Using Signed URLs
|
321
338
|
#
|
322
339
|
# Access without authentication can be granted to a file for a specified
|
@@ -600,6 +617,34 @@ module Google
|
|
600
617
|
Storage::Service.new(
|
601
618
|
project_id, credentials, retries: retries, timeout: timeout))
|
602
619
|
end
|
620
|
+
|
621
|
+
##
|
622
|
+
# Creates an unauthenticated, anonymous client for retrieving public data
|
623
|
+
# from the Storage service. Each call creates a new connection.
|
624
|
+
#
|
625
|
+
# @param [Integer] retries Number of times to retry requests on server
|
626
|
+
# error. The default value is `3`. Optional.
|
627
|
+
# @param [Integer] timeout Default timeout to use in requests. Optional.
|
628
|
+
#
|
629
|
+
# @return [Google::Cloud::Storage::Project]
|
630
|
+
#
|
631
|
+
# @example Use `skip_lookup` to avoid retrieving non-public metadata:
|
632
|
+
# require "google/cloud/storage"
|
633
|
+
#
|
634
|
+
# storage = Google::Cloud::Storage.anonymous
|
635
|
+
#
|
636
|
+
# bucket = storage.bucket "public-bucket", skip_lookup: true
|
637
|
+
# file = bucket.file "path/to/public-file.ext", skip_lookup: true
|
638
|
+
#
|
639
|
+
# downloaded = file.download
|
640
|
+
# downloaded.rewind
|
641
|
+
# downloaded.read #=> "Hello world!"
|
642
|
+
#
|
643
|
+
def self.anonymous retries: nil, timeout: nil
|
644
|
+
Storage::Project.new(
|
645
|
+
Storage::Service.new(nil, nil, retries: retries, timeout: timeout)
|
646
|
+
)
|
647
|
+
end
|
603
648
|
end
|
604
649
|
end
|
605
650
|
end
|
@@ -49,6 +49,18 @@ module Google
|
|
49
49
|
# file = bucket.file "path/to/my-file.ext"
|
50
50
|
# file.download "path/to/downloaded/file.ext"
|
51
51
|
#
|
52
|
+
# @example Download a public file with an unauthenticated client:
|
53
|
+
# require "google/cloud/storage"
|
54
|
+
#
|
55
|
+
# storage = Google::Cloud::Storage.anonymous
|
56
|
+
#
|
57
|
+
# bucket = storage.bucket "public-bucket", skip_lookup: true
|
58
|
+
# file = bucket.file "path/to/public-file.ext", skip_lookup: true
|
59
|
+
#
|
60
|
+
# downloaded = file.download
|
61
|
+
# downloaded.rewind
|
62
|
+
# downloaded.read #=> "Hello world!"
|
63
|
+
#
|
52
64
|
class File
|
53
65
|
##
|
54
66
|
# @private The Connection object.
|
@@ -485,6 +497,18 @@ module Google
|
|
485
497
|
# downloaded.rewind
|
486
498
|
# downloaded.read #=> "Hello world!"
|
487
499
|
#
|
500
|
+
# @example Download a public file with an unauthenticated client:
|
501
|
+
# require "google/cloud/storage"
|
502
|
+
#
|
503
|
+
# storage = Google::Cloud::Storage.anonymous
|
504
|
+
#
|
505
|
+
# bucket = storage.bucket "public-bucket", skip_lookup: true
|
506
|
+
# file = bucket.file "path/to/public-file.ext", skip_lookup: true
|
507
|
+
#
|
508
|
+
# downloaded = file.download
|
509
|
+
# downloaded.rewind
|
510
|
+
# downloaded.read #=> "Hello world!"
|
511
|
+
#
|
488
512
|
def download path = nil, verify: :md5, encryption_key: nil
|
489
513
|
ensure_service!
|
490
514
|
if path.nil?
|
@@ -41,7 +41,6 @@ module Google
|
|
41
41
|
def initialize project, credentials, retries: nil, timeout: nil
|
42
42
|
@project = project
|
43
43
|
@credentials = credentials
|
44
|
-
@credentials = credentials
|
45
44
|
@service = API::StorageService.new
|
46
45
|
@service.client_options.application_name = "gcloud-ruby"
|
47
46
|
@service.client_options.application_version = \
|
@@ -53,7 +52,7 @@ module Google
|
|
53
52
|
@service.request_options.header ||= {}
|
54
53
|
@service.request_options.header["x-goog-api-client"] = \
|
55
54
|
"gl-ruby/#{RUBY_VERSION} gccl/#{Google::Cloud::Storage::VERSION}"
|
56
|
-
@service.authorization = @credentials.client
|
55
|
+
@service.authorization = @credentials.client if @credentials
|
57
56
|
end
|
58
57
|
|
59
58
|
def service
|
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.
|
4
|
+
version: 1.9.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: 2017-11-
|
12
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|