Question: I'm working on a REST API, **trying to upload a picture of user** with:

* [grape](https://github.com/intridea/grape) micro-framework
* [paperclip](https://github.com/thoughtbot/paperclip) gem but it's not working, showing this error
* rails version is 3.2.8

`No handler found for #<Hashie::Mash filename="user.png" head="Content-Disposition: form-data; name=\"picture\"; filename=\"user.png\"\r\nContent-Type: image/png\r\n" name="picture" tempfile=#<File:/var/folders/7g/b_rgx2c909vf8dpk2v00r7r80000gn/T/RackMultipart20121228-52105-43ered> type="image/png">`

I tried testing paperclip with a controller and it worked but when I try to upload via grape api its not working my post header is multipart/form-data

My code for the upload is this 

```
 user = User.find(20) 
 user.picture = params[:picture] 
 user.save! 

```

So if it is not possible to upload files via grape is there any alternative way to upload files via REST api?

Answer: 
Maybe a more consistent way to do this would be to define paperclip adapter for Hashie::Mash

```
module Paperclip
  class HashieMashUploadedFileAdapter < AbstractAdapter

    def initialize(target)
      @tempfile, @content_type, @size = target.tempfile, target.type, target.tempfile.size
      self.original_filename = target.filename
    end

  end
end

Paperclip.io_adapters.register Paperclip::HashieMashUploadedFileAdapter do |target|
  target.is_a? Hashie::Mash
end

```

and use it "transparently" 

```
 user = User.find(20) 
 user.picture = params[:picture] 
 user.save! 

```

added to wiki - <https://github.com/intridea/grape/wiki/Uploaded-file-and-paperclip>
For the sake of Rails 5.1 users this should do as well:

### /your/endpoint/path

```
params do
  required :avata, type: File
end

```

### users\_spec.rb

```
describe 'PATCH /users:id' do
  subject { patch "/api/users/#{user.id}", params: params }

  let(:user) { create(:user) }
  let(:params) do
    {
      avatar: fixture_file_upload("spec/fixtures/files/jpg.jpg", 'image/jpeg')
    }
  end

  it 'updates the user' do
    subject      
    updated_user = user.reload
    expect(updated_user.avatar.url).to eq(params[:avatar])
  end
end

```