Defect #3911 » uploading_attachment_file_with_jruby_v2.patch
app/controllers/application.rb | ||
---|---|---|
206 | 206 |
if attachments && attachments.is_a?(Hash) |
207 | 207 |
attachments.each_value do |attachment| |
208 | 208 |
file = attachment['file'] |
209 |
next unless file && file.size > 0
|
|
209 |
next unless file && (file.size > 0 || (file.is_a?(ActionController::UploadedTempfile) && File.size(file) > 0))
|
|
210 | 210 |
a = Attachment.create(:container => obj, |
211 | 211 |
:file => file, |
212 | 212 |
:description => attachment['description'].to_s.strip, |
app/models/attachment.rb | ||
---|---|---|
54 | 54 |
def file=(incoming_file) |
55 | 55 |
unless incoming_file.nil? |
56 | 56 |
@temp_file = incoming_file |
57 |
if @temp_file.size > 0 |
|
57 |
if @temp_file.size > 0 || (@temp_file.is_a?(ActionController::UploadedTempfile) && File.size(@temp_file) > 0)
|
|
58 | 58 |
self.filename = sanitize_filename(@temp_file.original_filename) |
59 | 59 |
self.disk_filename = Attachment.disk_filename(filename) |
60 | 60 |
self.content_type = @temp_file.content_type.to_s.chomp |
61 |
self.filesize = @temp_file.size |
|
61 |
self.filesize = (@temp_file.size > 0)? @temp_file.size : File.size(@temp_file) |
|
62 |
else |
|
63 |
logger.debug("temp_file size is lower or equal to 0") |
|
62 | 64 |
end |
63 | 65 |
end |
64 | 66 |
end |
... | ... | |
70 | 72 |
# Copies the temporary file to its final location |
71 | 73 |
# and computes its MD5 hash |
72 | 74 |
def before_save |
73 |
if @temp_file && (@temp_file.size > 0) |
|
75 |
if @temp_file && (@temp_file.size > 0 || (@temp_file.is_a?(ActionController::UploadedTempfile) && File.size(@temp_file) > 0))
|
|
74 | 76 |
logger.debug("saving '#{self.diskfile}'") |
75 | 77 |
md5 = Digest::MD5.new |
76 | 78 |
File.open(diskfile, "wb") do |f| |
- « Previous
- 1
- 2
- Next »