paperclip-gcs 0.3.0 → 0.3.2

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: 0276c99a9ac183647cbb56a7e76a18e9628804f92d1cc43d065f30cf420025eb
4
- data.tar.gz: 19cb24cc258aa9f7ce6da3f12d3ac10d30a9bdf7f884c8518743a6e40b976c1c
3
+ metadata.gz: a1d92a7ec7300528df2c69939eca97548b3cbb482427b15e3e8e63fcdccc456a
4
+ data.tar.gz: 36a2ca6b9a42f01266980f76c62443e0d5b68519fbd78d1e8229570b6614111e
5
5
  SHA512:
6
- metadata.gz: b9db32a7a98bc072dba039c43b3bfdd938ce35a28d653a74ca235d5ab688eae1d38fafb3236d6da6fba22a9aba4552400a6d3df598dad78552a2a8922fb1c9a0
7
- data.tar.gz: 39f21cb173009e17497c5581495900fd5213c8314efa2b09beaf6616004c282bc735fff119ec298a2960857b80d89a7c639dc02be73a24a20893d3c0b914ace0
6
+ metadata.gz: 8a35c54927a1920a05016b0f0053ced96374860164457786e4a9c30a18dbb60152cd28264019766cd93c2627eb1dde0ad328a4881d929f6f57dcb8b5881dfb84
7
+ data.tar.gz: 4a6a26ec94dcbec160fa73e3b709b601661ee6c514ac1728480654fba12d64e913d5506006351872d1e9544a76bf63d007db0e3c898b606755b3a30834a2ec83
data/README.md CHANGED
@@ -184,6 +184,14 @@ gcs_storage_class: :multi_regional
184
184
 
185
185
  The Cache-Control metadata allows you to control whether and for how long browser and Internet caches are allowed to cache your objects.
186
186
 
187
+ ### gcs_content_disposition
188
+
189
+ The Content-Disposition metadata allows you to specify the presentation of the object in the browser.
190
+
191
+ ### gcs_content_type
192
+
193
+ The Content-Type metadata allows you to specify the content type of the object. By default it will use the file content type.
194
+
187
195
  ### Interpolates
188
196
 
189
197
  #### :gcs_alias_url
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Gcs
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ module Paperclip
14
14
  clients[config] ||= Google::Cloud.storage(
15
15
  config[:project],
16
16
  config[:keyfile],
17
- config.slice(:scope, :retries, :timeout)
17
+ **config.slice(:scope, :retries, :timeout)
18
18
  )
19
19
  end
20
20
 
@@ -23,6 +23,8 @@ module Paperclip
23
23
  @gcs_permissions = normalize_style(@options[:gcs_permissions])
24
24
  @gcs_storage_class = normalize_style(@options[:gcs_storage_class])
25
25
  @gcs_cache_control = normalize_style(@options[:gcs_cache_control])
26
+ @gcs_content_type = normalize_style(@options[:gcs_content_type])
27
+ @gcs_content_disposition = normalize_style(@options[:gcs_content_disposition])
26
28
 
27
29
  unless @options[:url].to_s.match(%r{\A:gcs_(alias|path|domain)_url\z}) || @options[:url] == ":asset_host".freeze
28
30
  @options[:path] = path_option.gsub(/:url/, @options[:url]).sub(%r{\A:rails_root/public/system}, "".freeze)
@@ -70,14 +72,15 @@ module Paperclip
70
72
  log("saving #{path(style)}")
71
73
 
72
74
  opts = {
73
- content_type: file.content_type,
75
+ content_type: gcs_content_type(file, style),
76
+ content_disposition: gcs_content_disposition(style),
74
77
  cache_control: gcs_cache_control(style),
75
78
  encryption_key: gcs_encryption_key,
76
79
  acl: gcs_permissions(style),
77
80
  storage_class: gcs_storage_class(style),
78
81
  metadata: gcs_metadata(style),
79
82
  }
80
- gcs_bucket.upload_file(file.path, path(style), opts)
83
+ gcs_bucket.upload_file(file.path, path(style), **opts)
81
84
  end
82
85
  after_flush_writes
83
86
  @queued_for_write = {}
@@ -141,6 +144,14 @@ module Paperclip
141
144
  unwrap_proc(@gcs_permissions[style] || @gcs_permissions[:default], self, style)
142
145
  end
143
146
 
147
+ def gcs_content_type(file, style = default_style)
148
+ unwrap_proc(@gcs_content_type[style] || @gcs_content_type[:default], self, style) || file.content_type
149
+ end
150
+
151
+ def gcs_content_disposition(style = default_style)
152
+ unwrap_proc(@gcs_content_disposition[style] || @gcs_content_disposition[:default], self, style)
153
+ end
154
+
144
155
  def gcs_storage_class(style = default_style)
145
156
  unwrap_proc(@gcs_storage_class[style] || @gcs_storage_class[:default], self, style)
146
157
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-gcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daichi HIRATA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-13 00:00:00.000000000 Z
11
+ date: 2023-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kt-paperclip