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 +5 -5
- data/CHANGELOG.md +3 -0
- data/README.md +4 -0
- data/lib/s3_assets_uploader/config.rb +12 -1
- data/lib/s3_assets_uploader/uploader.rb +3 -0
- data/lib/s3_assets_uploader/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4ef7284ec8a4e6f67ef449bd755accb7f66409512f856eb6c99056320167f528
|
4
|
+
data.tar.gz: 36ba9f6e43677cea5b177fc1584ce0bdaf171c6a3347508bfcd6b0f350aef2d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7288f6c0a161604163656568303961e425d38a66e8a686019db4cbadf24c1f96197084db96a8c68b6901ab420a0eb8ad8fb141a754f7ce563497c3a190ab58fc
|
7
|
+
data.tar.gz: 0f5a3f7226a34edb70e95f0fca1e283496d82aedf76801136f3d6da0d786c6b656414ad07033201b8399b0f37f812c7e887d80b39df7b66bd965567c5c9a4454
|
data/CHANGELOG.md
CHANGED
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
|
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
|
+
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:
|
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
|
-
|
126
|
-
|
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: []
|