wordnik/swagger-js — pull request #134 by mrhanlon (2014-09-22 15:48:45+00:00)
Title: add support for POSTing FormData objects with jQuery

I needed to be able to post Blobs created on the client. Either it's not supported or I am not familiar enough with Shred to get this working. However, I was able to get it working with jQuery. By modifying the processing of the body param to allow a FormData object to pass-through and letting jQuery process the multipart body, POSTing blobs is working.

Excerpt for API spec:
```javascript
...
{
"method": "POST",
"nickname": "importToDefaultSystem",
"notes": "This will return a handle to the file upload.",
"consumes": [
"multipart/form-data"
],
"parameters": [
{
"allowMultiple": false,
"description": "The path of the file relative to the user's default storage location.",
"name": "sourcefilePath",
"paramType": "path",
"required": true,
"type": "string"
},
{
"allowMultiple": false,
"description": "The file upload request",
"name": "body",
"paramType": "body",
"required": true,
"type": "FileUploadRequest"
}
],
"summary": "Import a file via direct upload or importing from a url to the user's default storage location.",
"type": "SingleRemoteFileResponse"
},
...
"FileUploadRequest": {
"id": "FileUploadRequest",
"name": "",
"properties": {
"fileType": {
"description": "",
"type": "string"
},
"callbackURL": {
"description": "",
"type": "string"
},
"fileName": {
"description": "",
"type": "string"
},
"urlToIngest": {
"description": "",
"type": "string"
},
"fileToUpload": {
"description": "",
"type": "File"
}
}
}
```

Example usage:
```javascript
data = new FormData();
data.append('fileToUpload', new Blob(['testing 123 456 789 10'], {'type': 'text/plain'}), 'testing123.txt');
data.append('fileName', 'testing123.txt');
Agave.api.files.importToDefaultSystem({sourcefilePath: 'path/to/upload/directory', body:data});
```