Reputation: 15491
Would it be possible to feed a single.jpg true carrierwave? Using jpegcam Im generating a temp.jpg and would like to feed this in carrierwave so it gets stored in the photos table and generate the thumbnails based on the /uploaders/photo_uploader.rb
Any way to feed a single jpg to carrierwave?
def upload
File.open(upload_path, 'w:ASCII-8BIT') do |f|
f.write request.raw_post
end
render :text => "ok"
end
private
def upload_path # is used in upload and create
file_name = ("webcam_1.jpg")
File.join(::Rails.root.to_s, 'public', 'uploads', file_name)
Photo.create(:file => File.open("#{Rails.root}/public/uploads/#{file_name}"))
end
Upvotes: 0
Views: 115
Reputation: 9700
If I understand your question correctly, you just want to create a Photo from a file? Assuming your Photo class has an 'image' field that Carrierwave is using, that would be this:
Photo.create(:image => File.open("#{Rails.root}/public/uploads/#{file_name}"))
Upvotes: 1