Gallery3:API:REST:Examples - Gallery Codex
Personal tools

Gallery3:API:REST:Examples

From Gallery Codex

Uploading a new file

To upload a new file, use a POST request to the parent album URL, providing the actual file (and filename), along with the new entity's details as a MIME multipart body.

Request

Parameters:

  • entity: a JSON-encoded object containing the fields of the new entity (name, description, etc. - *not tags*)
  • file: the picture data and filename
 POST /gallery3/index.php/rest/item/1 HTTP/1.1
 X-Gallery-Request-Method: post
 X-Gallery-Request-Key: ...
 Content-Length: 142114
 Content-Type: multipart/form-data; boundary=roPK9J3DoG4ZWP6etiDuJ97h-zeNAph
 
 
 --roPK9J3DoG4ZWP6etiDuJ97h-zeNAph
 Content-Disposition: form-data; name="entity"
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
 
 {"name":"Voeux2010.jpg","type":"photo"}
 --roPK9J3DoG4ZWP6etiDuJ97h-zeNAph
 Content-Disposition: form-data; name="file"; filename="Voeux2010.jpg"
 Content-Type: application/octet-stream
 Content-Transfer-Encoding: binary
 
 *** picture data ***
 --roPK9J3DoG4ZWP6etiDuJ97h-zeNAph

Note: do not forget to put a blank line between "Content-Transfer-Encoding: binary" and your picture data.

Response

The response is a simple JSON-encoded object containing the URL of the new entity

 {"url":"http://www.example.com/gallery3/index.php/rest/item/13"}