I asked a similar question here:
How do I upload a file with metadata using a REST web service?
You basically have three choices:
- Base64 encode the file, at the expense of increasing the data size by around 33%, and add processing overhead in both the server and the client for encoding/decoding.
- Send the file first in a
multipart/form-data
POST, and return an ID to the client. The client then sends the metadata with the ID, and the server re-associates the file and the metadata.
- Send the metadata first, and return an ID to the client. The client then sends the file with the ID, and the server re-associates the file and the metadata.