Use Paperclip in rack app like sinatra and how to write test
You’ll find rack parse uploaded file in different format to Rails
Here is the format in rack app.
You can simply covert it to right format.
yourModel = YourModel.new(:image => to_paperclip(params['image']))
yourModel.save
end
def to_paperclip(image)
paperclip = {}
paperclip['tempfile'] = image[:tempfile]
paperclip['filename'] = image[:filename]
paperclip['content_type'] = image[:type]
paperclip['size'] = image[:tempfile].size
paperclip
end
How to test
file = Rack::Test::UploadedFile.new(filename, "image/png")
post "/api/v1/some_api", {:image => file}
# should have image uploaded

