umanni-multipart-post 0.0.0.1 → 0.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,4 +17,24 @@ module FileUploadIO
|
|
17
17
|
EOS
|
18
18
|
file_io
|
19
19
|
end
|
20
|
+
|
21
|
+
def self.new(file_path, content_type, file_content)
|
22
|
+
raise ArgumentError, "File content type required" unless content_type
|
23
|
+
File.open(file_path, "w") {|f| f << file_content}
|
24
|
+
file_io = File.open(file_path, "rb")
|
25
|
+
file_io.instance_eval(<<-EOS, __FILE__, __LINE__)
|
26
|
+
def content_type
|
27
|
+
"#{content_type}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def file_name
|
31
|
+
"#{File.basename(file_path)}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def file_size
|
35
|
+
"#{File.size(file_path)}".to_i
|
36
|
+
end
|
37
|
+
EOS
|
38
|
+
file_io
|
39
|
+
end
|
20
40
|
end
|
data/lib/multi_part/version.rb
CHANGED