[thelist] REST RPC upload

Bill Moseley moseley at hank.org
Sun Feb 7 09:08:02 CST 2010

We are adding a REST API that uses JSON for the serialization of the request
(i.e. what would be the posted parameters in a urlencoded web post).

The API needs to accept file uploads.

Each file uploaded requires additional meta data such as filename,
last-modified time, author, etc.  None of that meta data is used as a
primary key.  The application must examine the upload *and* associated meta
data and either may reject the upload based on any of the data or accept it
and create a new primary key.  In the REST API this would be a POST and the
response would return either failure or the location of the newly created
entity (URL to access the upload).

The web application uses 'multipart/form-data' to serialize the request,
which is designed just for this. The web interface also allow submitting
multiple uploads in the same request, which is no problem.

My question is how should the REST-based API for this kind of file upload

The requirement that the request includes both the upload file data and the
associated meta data is what I'm having a problem with.  I could, of course,
just include the file data in the JSON like any other parameter (like author
or filename) but that has the potential to make the JSON request body very
large.  The JSON tools I've looked at require that the entire JSON string be
in memory which is not desirable, especially if the upload file is big.

I asked similar question on another list, but it was more implementation
specific.  Sorry for any duplicates.  I want to look at how the API should
look and then work on how to implement in a way that will work technically
for our servers.


Bill Moseley
moseley at hank.org

More information about the thelist mailing list