s3_assets_uploader 0.1.1 → 0.2.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
2
  SHA1:
3
- metadata.gz: 53953131c4d882031e21536bbe0b018fb44e3557
4
- data.tar.gz: 09804e172de8b1be505280a76ab45dfba90689e0
3
+ metadata.gz: d76723a14ca4cc1eaa57550a911870b9b9fca01d
4
+ data.tar.gz: 1ea0ea3af4123d4e1cb93271a6540aa978e97e9d
5
5
  SHA512:
6
- metadata.gz: 9eaf094a230df629d45232425858979f2cd6176a06b51f2985d3e624b41e68e8e2b300c132f55071faa84188ae5e2b7e38bef852f55a047e0c7b565b54e4df39
7
- data.tar.gz: c8cee3d611540af727beb9abf18aabacc2c075151f96d9f4708fb49521f594de5c3885d035acdf4d3150e0286abf5c765a2e5e5125483f5bd11f46876a778f99
6
+ metadata.gz: 85f4b2575cc25c7d9999a204f142ba3255a67a9fce2fbaf648bfcdc6f519a616d9ba7a1c9a10d5f6f55dbb18ee014197ea1b2f88f58e83cb6518b6f2f267ffe2
7
+ data.tar.gz: ca73f6074b9ac9368fb8e3e0ec0e50b4e0566ff483cabfa35d07dc66bf424d4b30f46aef5d23c5c8e3feefcb497c0ef43d58bdba175ee1af4f7cd3f22023015b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.0
2
+ - Now Content-Type is automatically specified from asset's filename.
3
+ - https://github.com/eagletmt/s3_assets_uploader/pull/2
4
+
1
5
  # 0.1.1
2
6
  - Add `config.additional_paths`
3
7
 
@@ -1,4 +1,5 @@
1
1
  require 's3_assets_uploader/config'
2
+ require 'mime/types'
2
3
 
3
4
  module S3AssetsUploader
4
5
  class Uploader
@@ -28,6 +29,7 @@ module S3AssetsUploader
28
29
  body: f,
29
30
  bucket: @config.bucket,
30
31
  key: compute_asset_key(path),
32
+ content_type: guess_content_type(path),
31
33
  )
32
34
  end
33
35
  end
@@ -41,6 +43,15 @@ module S3AssetsUploader
41
43
  end
42
44
  end
43
45
 
46
+ def guess_content_type(path)
47
+ mime_type = MIME::Types.type_for(path.basename.to_s).first
48
+ if mime_type
49
+ mime_type.content_type
50
+ else
51
+ 'application/octet-stream'
52
+ end
53
+ end
54
+
44
55
  def relative_path(path)
45
56
  path.relative_path_from(@config.public_path)
46
57
  end
@@ -1,3 +1,3 @@
1
1
  module S3AssetsUploader
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "aws-sdk", ">= 2.0"
23
+ spec.add_dependency "mime-types"
23
24
  spec.add_development_dependency "bundler"
24
25
  spec.add_development_dependency "rake"
25
26
  spec.add_development_dependency "rspec", ">= 3.0"
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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-01 00:00:00.000000000 Z
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mime-types
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement