carrierwave-mimetype-magic 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -1
- data/carrierwave-mimetype-magic.gemspec +2 -2
- data/lib/carrierwave-mimetype-magic.rb +4 -3
- data/lib/carrierwave-mimetype-magic/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54d641eebdc2671db4019f5ff512691ba7b292c3
|
4
|
+
data.tar.gz: 895342b926cf4e3a67bee6ba43a796e29b2a3149
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b3a8498b75a7ebd3400f3eff7d7b57dd4dbe4aa53e88e9c2fe0f732db15bd1b2411d330a8b8b64d5409e52199c70766b6d0245f993f6db19e85ed71abb9da15
|
7
|
+
data.tar.gz: 2d1413a16d391a791c7d955f301a5406da5a23b32b98243abcc57fcc4f4f4303e05ba0e31e577a984f62c30deaff3d94050e6584de9ebd0365b06063d5d41737
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# CarrierWave::MimetypeMagic
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/carrierwave-mimetype-magic.svg)](https://badge.fury.io/rb/carrierwave-mimetype-magic)
|
2
3
|
|
3
4
|
By default, carrierwave uses the uploaded file's extension to guess the content type. Sometimes you'd prefer to actually look at the file and set the content type based on that, so users can't upload php files as *i\_am\_lying.jpg* and have the server try to process them as images.
|
4
5
|
|
@@ -30,7 +31,7 @@ And now uploaded files' content\_type will be set appropriately, and uploads wil
|
|
30
31
|
|
31
32
|
## History
|
32
33
|
|
33
|
-
Originally based on the [carrierwave-mymetype-fu](https://github.com/deviantech/carrierwave-mimetype-fu) (that based on [carrierwave-magic](https://github.com/glebtv/carrierwave-magic)) gem, but using [
|
34
|
+
Originally based on the [carrierwave-mymetype-fu](https://github.com/deviantech/carrierwave-mimetype-fu) (that based on [carrierwave-magic](https://github.com/glebtv/carrierwave-magic)) gem, but using [mimemagic](https://github.com/minad/mimemagic) rather than MimetypeFu, that works incorrect with MS files.
|
34
35
|
|
35
36
|
## Contributing
|
36
37
|
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.authors = ["Piton4eg"]
|
10
10
|
gem.email = ["piton4eg@mail.ru"]
|
11
11
|
gem.description = %q{Real mime-types for carrierwave}
|
12
|
-
gem.summary = %q{Carrierwave extension to set file content type and extension with
|
12
|
+
gem.summary = %q{Carrierwave extension to set file content type and extension with mimemagic from real mime type}
|
13
13
|
gem.homepage = "https://github.com/piton4eg/carrierwave-mimetype-magic"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_runtime_dependency "
|
20
|
+
gem.add_runtime_dependency "mimemagic", '~> 0.3.0'
|
21
21
|
gem.add_runtime_dependency "carrierwave", '~> 0.10.0'
|
22
22
|
|
23
23
|
gem.license = 'MIT'
|
@@ -8,9 +8,10 @@ module CarrierWave
|
|
8
8
|
alias_method_chain :cache!, :mimetype_magic
|
9
9
|
|
10
10
|
begin
|
11
|
-
require '
|
11
|
+
require 'mimemagic'
|
12
|
+
require 'mimemagic/overlay'
|
12
13
|
rescue LoadError => e
|
13
|
-
e.message << ' (You may need to install the
|
14
|
+
e.message << ' (You may need to install the mimemagic gem)'
|
14
15
|
raise e
|
15
16
|
end
|
16
17
|
end
|
@@ -28,7 +29,7 @@ module CarrierWave
|
|
28
29
|
|
29
30
|
begin
|
30
31
|
# Collect information about the real content type
|
31
|
-
real_content_type =
|
32
|
+
real_content_type = MimeMagic.by_magic(opened_file).type
|
32
33
|
valid_extensions = Array(MIME::Types[real_content_type].try(:first).try(:extensions))
|
33
34
|
|
34
35
|
# Set proper content type, and update filename if current name doesn't match reach content type
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-mimetype-magic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piton4eg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: mimemagic
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: carrierwave
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +77,6 @@ rubyforge_project:
|
|
77
77
|
rubygems_version: 2.5.2
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
|
-
summary: Carrierwave extension to set file content type and extension with
|
80
|
+
summary: Carrierwave extension to set file content type and extension with mimemagic
|
81
81
|
from real mime type
|
82
82
|
test_files: []
|