captured 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/captured +2 -0
- data/lib/captured/file_uploader.rb +3 -0
- data/lib/captured/uploaders/imageshack_uploader.rb +14 -2
- metadata +1 -11
data/bin/captured
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
3
|
require 'cgi'
|
4
|
-
require 'mime/types'
|
5
4
|
|
6
5
|
# Adapted from http://codesnippets.joyent.com/posts/show/1156
|
7
6
|
class ImageshackUploader
|
@@ -114,11 +113,24 @@ class FileParam
|
|
114
113
|
@k = k
|
115
114
|
@filename = filename
|
116
115
|
@content = content
|
116
|
+
@extension_index = {
|
117
|
+
'jpg' => "image/jpeg",
|
118
|
+
'jpeg' => "image/jpeg",
|
119
|
+
'png' => "image/png",
|
120
|
+
'bmp' => "image/bmpimage/x-bmp",
|
121
|
+
'tiff' => "image/tiff",
|
122
|
+
'tif' => "image/tiff"}
|
117
123
|
end
|
118
124
|
|
125
|
+
def type_for(filename)
|
126
|
+
ext = filename.chomp.downcase.gsub(/.*\./o, '')
|
127
|
+
@extension_index[ext]
|
128
|
+
end
|
129
|
+
|
130
|
+
|
119
131
|
def to_multipart
|
120
132
|
return "Content-Disposition: form-data; name=\"#{CGI::escape(k)}\"; filename=\"#{filename}\"\r\n" +
|
121
|
-
"Content-Type: #{
|
133
|
+
"Content-Type: #{type_for(@filename)}\r\n\r\n" + content + "\r\n"
|
122
134
|
end
|
123
135
|
end
|
124
136
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: captured
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Sexton
|
@@ -22,16 +22,6 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: mime-types
|
27
|
-
type: :runtime
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
25
|
description: Because <shift>-<command>-4 is the single most useful shorcut in Macdom
|
36
26
|
email: csexton@gmail.com
|
37
27
|
executables:
|