In my Rails 3 application I have multiple models, and each model is associated with another model.
User model
has_many :departments
accepts_nested_attributes_for :departments
Department Model
has_many :projects
accepts_nested_attributes_for :projects
I am trying to insert data through the postman REST client using JSON. I have found some of the formats except there is an image upload field in the User model that I am going to handle with the PaperClip gem.
Through my rails view it is working fine, but how do I upload an image using postman?
For uploading through REST client I need the JSON format equivalent of my image.
Is there any way to embed the image in json so I can use the postman rest client?
– Using Base64
— Taken from What is base 64 encoding used for?
So one way of doing it is to put a Base64 string inside your json request and have your app decode it.
Here is what your model could do
But a quick look at POSTMAN tells me you have to do the encoding your self.
Alternatively
you can just pass a url instead of the data – if the url is pointing to resource available on the net.
Update
Postman actually allows you to construct a post request with an image attached. Isnt that what you are looking for ?