y9v/carrierwave-base64

Uploading multiple Images using JSON API

Mohakjuneja opened this issue · 3 comments

Hi there! I need to upload multiple images to my model using the JSON API. I've been able to do it for a single image thanks to this link
https://gist.github.com/ifightcrime/9291167a0a4367bb55a2
But I've been failing at improvising the approach to upload multiple images. I'm using the the carrierwave mongoid gem along with the master branch of carrierwave and I've made the recommended changes to my model and controller. The files I'm trying to upload get stored in the cache directory but not in the intended store directory. I believe I'm not passing the file correctly to the params.
Here what my params look like just before I create an object
{"campus"=>"569df3c4be84c511c0000001", "course"=>"569dfe1cbe84c511c0000006", "subject"=>"56a0c4debe84c50d2f000006", "batch"=>"2015", "title"=>"Meteorite", "assets"=>#<ActionDispatch::Http::UploadedFile:0x00000004459ad0 @tempfile=#<Tempfile:/tmp/upload-image20160304-6427-175khj8>, @original_filename="upload-image.jpeg", @content_type=nil, @headers=nil>}
The assets key contains all information related to the files being uploaded
I've hit a dead end trying to figure this out. Please help!

y9v commented

@Mohakjuneja do you use carrierwave-base64 gem, or the gist you mentioned above?

I came across the gem quite some time after I had implemented the functionality using the gist. It link says the functionality has now been extracted to carrierwave-base64. Honestly, I've tried everything and if migrating from the gist to the gem solves my problem of uploading multiple images, I'll gladly do it.
Thanks @lebedev-yury!

y9v commented

Well, I'm sorry to say that, but i'm afraid I can't help you, because I have no idea about your app and the implementation. Try doing that with a gem, if you will have some problems, i will help you. But in this case, at least provide some code examples please.