Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use carrierwave without a model in rails?

I am trying to save a png in my rails app using the below code

uploader = AvatarUploader.new
uploader.store!(params[:image])

But it's throwing ArgumentError (invalid byte sequence in UTF-8)

What am i doing wrong here?

I am posting it via an ios app using AFNetworking.

like image 510
Kanishka Avatar asked Nov 19 '15 22:11

Kanishka


1 Answers

Here's a quick excerpt from this answer adapted to your question:

uploader = AvatarUploader.new
File.open(params[:image]) do |file|
  something = uploader.store!(file)
end
uploader.retrieve_from_store!(self.file_name)
like image 78
bosskovic Avatar answered Oct 18 '22 19:10

bosskovic