s3_assets_uploader 0.4.0 → 0.5.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
- SHA1:
3
- metadata.gz: 2cd372da318416fefcd37f29244fcaf9f4956c11
4
- data.tar.gz: b2e549e6d79f58f173cf688b1c13928c9b191909
2
+ SHA256:
3
+ metadata.gz: 4ef7284ec8a4e6f67ef449bd755accb7f66409512f856eb6c99056320167f528
4
+ data.tar.gz: 36ba9f6e43677cea5b177fc1584ce0bdaf171c6a3347508bfcd6b0f350aef2d3
5
5
  SHA512:
6
- metadata.gz: 4fc5eb263c9f82957d1012e89708ffaa1b7b5c5268b4bdf68066f435e5769f28661b455df78c7fe04be321594de043dbc598647a53d9fb590af926fe26907506
7
- data.tar.gz: 6a7ea4dc1693c6fe61b11450ac1e36f0a15ad6a591183f4aebf700e60c94676127269befcad341c6dee78c037379183284665007165a0c576840e1913640d0b5
6
+ metadata.gz: 7288f6c0a161604163656568303961e425d38a66e8a686019db4cbadf24c1f96197084db96a8c68b6901ab420a0eb8ad8fb141a754f7ce563497c3a190ab58fc
7
+ data.tar.gz: 0f5a3f7226a34edb70e95f0fca1e283496d82aedf76801136f3d6da0d786c6b656414ad07033201b8399b0f37f812c7e887d80b39df7b66bd965567c5c9a4454
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.5.0
2
+ - Add `config.content_type` option
3
+
1
4
  # 0.4.0
2
5
  - Use aws-sdk v3
3
6
 
data/README.md CHANGED
@@ -54,6 +54,10 @@ end
54
54
  - `config.cache_control`
55
55
  - cache_control option for S3
56
56
  - Default: `"max-age=2592000, public"`
57
+ - `config.content_type`
58
+ - Set custom handler to determine content-type of the object
59
+ - When the handler returns nil, the content-type is guessed from its extension
60
+ - Default: `nil`
57
61
 
58
62
  ## Development
59
63
 
@@ -1,7 +1,7 @@
1
1
  require 'aws-sdk-s3'
2
2
 
3
3
  module S3AssetsUploader
4
- class Config < Struct.new(:s3_client, :bucket, :assets_path, :assets_prefix, :additional_paths, :cache_control)
4
+ class Config < Struct.new(:s3_client, :bucket, :assets_path, :assets_prefix, :additional_paths, :cache_control, :content_type)
5
5
  class ValidationError < StandardError
6
6
  end
7
7
 
@@ -12,6 +12,7 @@ module S3AssetsUploader
12
12
  self.assets_path = DEFAULT_ASSETS_PATH
13
13
  self.cache_control = DEFAULT_CACHE_CONTROL
14
14
  self.additional_paths = []
15
+ self.content_type = nil
15
16
  end
16
17
 
17
18
  def assets_path
@@ -33,6 +34,16 @@ module S3AssetsUploader
33
34
  true
34
35
  end
35
36
 
37
+ def content_type(&block)
38
+ self[:content_type] = block
39
+ end
40
+
41
+ def guess_content_type(path)
42
+ return unless self[:content_type]
43
+
44
+ self[:content_type].call(path)
45
+ end
46
+
36
47
  private
37
48
 
38
49
  def create_default_client
@@ -45,6 +45,9 @@ module S3AssetsUploader
45
45
  end
46
46
 
47
47
  def guess_content_type(path)
48
+ content_type = @config.guess_content_type(path)
49
+ return content_type if content_type
50
+
48
51
  mime_type = MIME::Types.type_for(path.basename.to_s).first
49
52
  if mime_type
50
53
  mime_type.content_type
@@ -1,3 +1,3 @@
1
1
  module S3AssetsUploader
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_assets_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-26 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -107,7 +107,7 @@ homepage: https://github.com/eagletmt/s3_assets_uploader
107
107
  licenses:
108
108
  - MIT
109
109
  metadata: {}
110
- post_install_message:
110
+ post_install_message:
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib
@@ -122,9 +122,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  requirements: []
125
- rubyforge_project:
126
- rubygems_version: 2.6.11
127
- signing_key:
125
+ rubygems_version: 3.2.13
126
+ signing_key:
128
127
  specification_version: 4
129
128
  summary: Upload Rails assets to S3.
130
129
  test_files: []