I have an api that will be accessed by a URI like this:
POST: http://<domain>/app/rest/colors
This post request will send some string parameters (i.e name: "red") along with a file. Ideally I would like the data given to the API in JSON format but if there isn't a way to pass a file to JSON then I'm open to other formats as well. 
Currently, when I'm taking parameters from a form post, my controller action looks kind of like this:
def save() {
    def colorInstance = new Color(params)
    CommonsMultipartFile file = request.getFile('filename')
    fileUploadService.upload(file)
    if (colorInstance.save(flush: true)) {
            flash.message = "Created"
            redirect(action: "list")
    }
    else {
        render(view:  "create", model: [colorInstance: colorInstance])
    }
}
Question
- How can a file be passed to the REST API? Can it still be JSON?
- How can I access that file in my saveaction
- How can I test the action with curl
For example typically I do
curl -XPOST http://<domain>/app/rest/colors -d '{
       "name": "red",
       "shade": "light"
}'
But now I would like to send a file as well along with those two parameters
 
     
     
    