Bluemelon API‎ > ‎

File Upload

uploads an item (photo) and stores it on the server together with the related information

Authentication:

Yes (see here for details)

General

The file upload is protocol-independent. For direct upload, all files should be sent to the following URL using either the HTTP PUT method or the HTTP MULTIPART POST method :

http://www.bluemelon.com/api/upload/

- the size of the request must not exceed 104 857600 bytes ( = 100 MB )

- since the body of the message consists solely of the binary data of the item to be uploaded, the arguments (such as the album id or the authentication token) have to be sent in the HTTP header for the PUT request and as values in the form data for the POST request

For indirect upload, there is also the possibility to upload files from a URL using the bluemelon.items.uploadFromURL method.

Error Codes

Concerning the relevant error codes, see the "Upload Errors" section in the complete list of error codes


HTTP PUT Upload

Headers

(required - generated automatically) Content-Length - a standard HTTP header that must match the number of bytes sent in the body (the image file) - this value must not exceed 104857600
(required) Content-Md5 - the MD5 checksum of the data in the body (the image file)
(required) X-BlueMelon-Token - the authentication token
(required) X-BlueMelon-ResponseType - must be set to XML for the time being
(optional) X-BlueMelon-FileName - the filename the file should be renamed to
(optional) X-BlueMelon-AlbumID - if present, the uploaded item will be added to the album with this id
(optional) X-BlueMelon-FileCreatedDate - the time the file was created :  milliseconds since 00:00:00 GMT, Jan 1, 1970 - as long
(optional) X-BlueMelon-FileModifiedDate - the time the file was last modified :  milliseconds since 00:00:00 GMT, Jan 1, 1970 - as long
(optional) X-BlueMelon-Title - the new item name - of which only the first 50 characters are accepted
(optional) X-BlueMelon-Description - the new item description - of which only the first 3000 characters are accepted
(optional) X-BlueMelon-Tags - the new item tags - of which only the first 3000 characters are accepted

Response Example:

in the xml response after a successful upload, the bluemelon.Items.item name of node is replaced with the item name

<rsp status="ok" onrequest="bluemelon.upload">
<content>
<item id="326" date="2008-10-23 01:00:17.672 CEST" filename="image.jpg" size="481
2" type="UNKNOWN" subtype="UNKNOWN" title="image.jpg"/>
</content>
</rsp>

HTTP MULTIPART POST Upload

Header

(required - generated automatically) Content-Length - a standard HTTP header that must match the number of bytes sent in the body (the image file) - this value must not exceed 104857600

Arguments

(required) X-BlueMelon-Token - the authentication token
(required) X-BlueMelon-ResponseType - must be set to "XML" for the time being
(required) X-BlueMelon-BytesCount_{file_value_name} - must match the number of bytes sent in the body (the image file)
(required) X-BlueMelon-MD5Sum_{file_value_name} - the MD5 checksum of the data in the body (the image file)
(optional) X-BlueMelon-AlbumID - if present, the uploaded item will be added to the album with this id
(optional) X-BlueMelon-FileCreatedDate_{file_value_name} - the time the file was created :  milliseconds since 00:00:00 GMT, Jan 1, 1970 - as long
(optional) X-BlueMelon-FileModifiedDate_{file_value_name} - the time the file was last modified :  milliseconds since 00:00:00 GMT, Jan 1, 1970 - as long
(optional) X-BlueMelon-Title_{file_value_name} - the new item name - of which only the first 50 characters are accepted
(optional) X-BlueMelon-Description_{file_value_name} - the new item description - of which only the first 3000 characters are accepted
(optional) X-BlueMelon-Tags_{file_value_name} - the new item tags - of which only the first 3000 characters are accepted

- the {file_value_name} is to be replaced with the name of the value of the file argument

- in the POST request, the hereafter listed arguments have to be sent prior to the file itself :  X-BlueMelon-Token, X-BlueMelon-ResponseType, X-BlueMelon-BytesCount_{file_value_name}, X-BlueMelon-MD5Sum_{file_value_name}

Request Example

The following HTML form generates a valid POST request

<form action="http://www.bluemelon.com/api/upload/" method="post" enctype="multipart/form-data" >
<input type="hidden" name="X-BlueMelon-Token" value="43C80D9D6110F219C517130BE8507DAA87AE778"/>
<input type="hidden" name="X-BlueMelon-ResponseType" value="xml" />
<input type="hidden" name="X-BlueMelon-MD5BytesCount_theFileToBeSent" value="27458" />
<input type="hidden" name="X-BlueMelon-MD5Sum_theFileToBeSent" value="AAA789" />
<input name="theFileToBeSent" type="file" />
<input type="submit" value="Upload File" />
</form>

Response Example:

in the XML response after a successful upload, the bluemelon.Items.item name of node is replaced with the item name

<rsp status="ok" onrequest="bluemelon.upload">
<content>
<item id="326" date="2008-10-23 01:00:17.672 CEST" filename="image.jpg" size="481
2" type="UNKNOWN" subtype="UNKNOWN" title="image.jpg"/>
</content>
</rsp>
Comments