umanni-multipart-post 0.0.0.2 → 0.0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/multi_part/file_upload_io.rb +2 -21
- data/lib/multi_part/version.rb +1 -1
- metadata +1 -1
@@ -1,26 +1,7 @@
|
|
1
1
|
module FileUploadIO
|
2
|
-
def self.new(file_path, content_type)
|
2
|
+
def self.new(file_path, content_type, file_content = nil)
|
3
3
|
raise ArgumentError, "File content type required" unless content_type
|
4
|
-
|
5
|
-
file_io.instance_eval(<<-EOS, __FILE__, __LINE__)
|
6
|
-
def content_type
|
7
|
-
"#{content_type}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def file_name
|
11
|
-
"#{File.basename(file_path)}"
|
12
|
-
end
|
13
|
-
|
14
|
-
def file_size
|
15
|
-
"#{File.size(file_path)}".to_i
|
16
|
-
end
|
17
|
-
EOS
|
18
|
-
file_io
|
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}
|
4
|
+
File.open(file_path, "w") {|f| f << file_content} unless file_content.blank?
|
24
5
|
file_io = File.open(file_path, "rb")
|
25
6
|
file_io.instance_eval(<<-EOS, __FILE__, __LINE__)
|
26
7
|
def content_type
|
data/lib/multi_part/version.rb
CHANGED