carrierwave-google-storage 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carrierwave/google/storage/version.rb +1 -1
- data/lib/carrierwave/storage/gcloud_file.rb +15 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8a4f2b75d288ec70c7d458ce3c2ff83ebe1a892
|
4
|
+
data.tar.gz: 34a785ebacdaeeff8c6aa6458a484ac3722884e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b334339564c3d2995ef0707bf0a9990adb424d4f968da3f5cad689318e95b004f88213fba90b2ea046c9b17162c751cee702e70f2e5ab3102b87afdd28e77d1
|
7
|
+
data.tar.gz: 5ba58a130adccd9286265916caacf21982426eb04289ee2ca657871e044383910498f697a2c3da873252296fa0bce9dc6c6e3a93bd3ded06312d975d00f36e09
|
@@ -29,12 +29,13 @@ module CarrierWave
|
|
29
29
|
self.file_exists = true
|
30
30
|
yield
|
31
31
|
rescue Exception => exception
|
32
|
+
@file = nil
|
32
33
|
self.file_exists = false if (exception.class == ::Gcloud::Storage::ApiError) && (exception.message == "Not Found")
|
33
|
-
raise exception
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
def attributes
|
38
|
+
return unless file_exists
|
38
39
|
{
|
39
40
|
content_type: file.content_type,
|
40
41
|
size: file.size,
|
@@ -63,7 +64,8 @@ module CarrierWave
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def read
|
66
|
-
(
|
67
|
+
tmp_file = Tempfile.new(CarrierWave::Support::UriFilename.filename(file.name))
|
68
|
+
(file.download tmp_file.path, verify: :all).read
|
67
69
|
end
|
68
70
|
|
69
71
|
def store(new_file)
|
@@ -75,6 +77,17 @@ module CarrierWave
|
|
75
77
|
file.copy("#{uploader.store_dir}/#{new_path}")
|
76
78
|
end
|
77
79
|
|
80
|
+
def url(options = {})
|
81
|
+
return unless file_exists
|
82
|
+
uploader.gcloud_bucket_is_public ? public_url : authenticated_url
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def bucket
|
88
|
+
bucket ||= connection.bucket(uploader.gcloud_bucket)
|
89
|
+
end
|
90
|
+
|
78
91
|
def authenticated_url(options = {})
|
79
92
|
file.signed_url
|
80
93
|
end
|
@@ -87,16 +100,6 @@ module CarrierWave
|
|
87
100
|
end
|
88
101
|
end
|
89
102
|
|
90
|
-
def url(options = {})
|
91
|
-
uploader.gcloud_bucket_is_public ? public_url : authenticated_url
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def bucket
|
97
|
-
bucket ||= connection.bucket(uploader.gcloud_bucket)
|
98
|
-
end
|
99
|
-
|
100
103
|
end
|
101
104
|
end
|
102
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-google-storage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jasdeep Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|