Skip to content

Commit

Permalink
Upload fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattia Roccoberton committed May 22, 2018
1 parent 9bc377a commit bc28019
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/activeadmin/jfu_upload/engine.rb
Expand Up @@ -18,9 +18,10 @@ def upload_file( request, param, resource, field )
buffer = param.read
pos = m[1].to_i
if pos == 0
dir = Rails.root.join('public', 'uploads')
dir.mkdir unless File.exists?(dir)
field_data = { original_filename: param.original_filename, tempfile: dir.join(param.tempfile).to_s } # alternative: "#{resource.class.to_s.tableize}_#{resource.id}_#{Time.now.to_i}"
tempfile = Rails.root.join('tmp', "upload_#{Time.now.to_i}_#{resource.id}_#{field}")
field_data = { original_filename: param.original_filename, tempfile: tempfile }
# dir.mkdir unless File.exists?(dir)
# field_data = { original_filename: param.original_filename, tempfile: dir.join(param.tempfile).to_s } # alternative: "#{resource.class.to_s.tableize}_#{resource.id}_#{Time.now.to_i}"
resource.update_column field, YAML::dump( field_data )
mode = 'wb'
else
Expand Down
2 changes: 1 addition & 1 deletion lib/activeadmin/jfu_upload/version.rb
@@ -1,5 +1,5 @@
module ActiveAdmin
module JfuUpload
VERSION = '0.1.7'
VERSION = '0.1.8'
end
end

0 comments on commit bc28019

Please sign in to comment.