carrierwave-mimetype-fu 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/carrierwave-mimetype-fu.rb +10 -3
- data/lib/carrierwave-mimetype-fu/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52f231eaad6b4683e917538711254064ec8b0909
|
4
|
+
data.tar.gz: b9dba256eb51acf510230014e1cf1fc3401af03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aebe42202438818bbf42c214dc30e562baa8dbff1feee3257ac31065f4f40969884fcff161f0d20b12ec12f311ffb3ec82f19cd898c88ff2313770643730179f
|
7
|
+
data.tar.gz: 79dc60a5ca7dbcfba54588727167ff505d8dfc63699d20cd00ead8e17fa482c585e94379fe9d9bac6d3d24d3d4a2136c4b338e14339798e0fa09e617a1787f7b
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# carrierwave-mimetype-fu changelog
|
2
|
+
|
3
|
+
|
4
|
+
## `0.0.2`
|
5
|
+
|
6
|
+
* Also engage when given a remote file (CarrierWave::Uploader::Download::RemoteFile)
|
7
|
+
|
8
|
+
## `0.0.1`
|
9
|
+
|
10
|
+
* Added initial functionality. Only engages on direct file upload (ActionDispatch::Http::UploadedFile)
|
@@ -17,16 +17,23 @@ module CarrierWave
|
|
17
17
|
|
18
18
|
def cache_with_mimetype_fu_magic!(new_file = sanitized_file)
|
19
19
|
# Only step in on the initial file upload
|
20
|
-
|
20
|
+
opened_file = case new_file
|
21
|
+
when CarrierWave::Uploader::Download::RemoteFile then new_file.send(:file)
|
22
|
+
when ActionDispatch::Http::UploadedFile then File.open(new_file.path)
|
23
|
+
else nil
|
24
|
+
end
|
25
|
+
|
26
|
+
return cache_without_mimetype_fu_magic!(new_file) unless opened_file
|
27
|
+
|
21
28
|
|
22
29
|
begin
|
23
30
|
# Collect information about the real content type
|
24
|
-
real_content_type = File.mime_type?(
|
31
|
+
real_content_type = File.mime_type?(opened_file).split(';').first
|
25
32
|
valid_extensions = Array(MIME::Types[real_content_type].try(:first).try(:extensions))
|
26
33
|
|
27
34
|
# Set proper content type, and update filename if current name doesn't match reach content type
|
28
|
-
new_file.content_type = real_content_type
|
29
35
|
new_file = CarrierWave::SanitizedFile.new(new_file)
|
36
|
+
new_file.content_type = real_content_type
|
30
37
|
base, ext = new_file.send(:split_extension, new_file.original_filename)
|
31
38
|
ext = valid_extensions.first unless valid_extensions.include?(ext)
|
32
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-mimetype-fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kali Donovan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mimetype-fu
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- CHANGELOG.md
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|