mime-typer 0.2 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +2 -2
- data/README.md +9 -0
- data/lib/mime-typer.rb +2 -1
- data/mime-typer.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cde2142f2e3b81b5d4cd363bc57d4c26026f744f
|
4
|
+
data.tar.gz: 27bec553b6bf4dc984890df92d9365e9dd95197f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3702ce87a2770e9ecd833e1bb61ecdf3dbaa3c29a2a04e1cd62ddbd92b871b369f99131d6cff14cb657f70bf711d9fb85b812f8f9067b6ecb13b06950e0c53f1
|
7
|
+
data.tar.gz: 2a15a8daaf138847fcd4220f04c36fcccb84a78c2f1aebf038895b1de4f62675ca578f450a924c35400079b74c7f433e33e4aa463b0bddffd9facbc4e110289c
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2014 Piero Dotti
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
@@ -17,4 +17,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
17
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
18
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
19
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -24,3 +24,12 @@ You can also pass an already opened file:
|
|
24
24
|
|
25
25
|
myfile = File.open('path/to/my/image.jpg')
|
26
26
|
MIME::Typer.detect(myfile) # => 'image/jpg'
|
27
|
+
|
28
|
+
|
29
|
+
If you want to detect the MIME Type of a remote file you can use the `remote` method
|
30
|
+
|
31
|
+
MIME::Typer.remote('http://www.yoursite.com/image.png') # => 'image/png'
|
32
|
+
|
33
|
+
This will load only the first part of the file, so it's quite fast also with large remote files.
|
34
|
+
|
35
|
+
**Warning** this feature is quite experimental!
|
data/lib/mime-typer.rb
CHANGED
@@ -61,7 +61,8 @@ module MIME
|
|
61
61
|
def self.load_remote(uri, bytes = 200)
|
62
62
|
result = ''
|
63
63
|
uri = URI(uri)
|
64
|
-
|
64
|
+
ssl = uri.scheme == 'https'
|
65
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: ssl) do |http|
|
65
66
|
request = Net::HTTP::Get.new(uri.request_uri)
|
66
67
|
http.request(request) do |response|
|
67
68
|
result = response.socket.read(bytes)
|
data/mime-typer.gemspec
CHANGED