Open Photo API / Photo Upload
=======================
#### OpenPhoto, a photo service for the masses
----------------------------------------
1. [Purpose][purpose]
1. [Endpoint][endpoint]
1. [Parameters][parameters]
1. [Examples][examples]
* [Curl][example-curl]
* [PHP][example-php]
1. [Response][response]
* [Sample][sample]
----------------------------------------
### Purpose of the Photo Upload API
This API is used to upload a new photo for a user.
----------------------------------------
### Endpoint
_Authentication: required_
POST /photo/upload.json
### Parameters
1. photo (required), The photo to be uploaded.
* This can be the binary photo in multipart/formdata
* This can be the base64 encoded value of the photo in application/x-www-form-urlencoded
1. title (optional), _i.e. My first day at work_ - A string title to describe the photo.
1. description (optional), _i.e. A much longer description of my first day_ - A string to describe the photo in detail.
1. tags (optional), _i.e. dog,cat_ - A comma delimited string of alpha numeric strings.
1. dateUploaded (optional), _i.e. 1311059035_ - A unix timestamp of the date the photo was uploaded
1. dateTaken (optional), _i.e. 1311059035_ - A unix timestamp of the date the photo was taken which overrides EXIF data if present
1. latitude (optional), _i.e. 34.76_ - A decimal representation of latitude.
1. longitude (optional), _i.e. -87.45_ - A decimal representation of longitude.
1. returnOptions (optional), _i.e. 300x300xBW_ - A string instructing a specific version of the photo to be autogenerated.
The url will be present in the response as _requestedUrl_.
* 300x300 - A photo which maintains aspect ratio and fits inside a 300x300 square
* 1024x768xCR - A photo that's exactly 1024x768 pixels cropped to the center in an optimized manner
* 160x90xBWxCR - A photo that's cropped exactly to 160x90 in greyscale (black and white)
----------------------------------------
### Examples
#### Command line curl
curl -F 'photo=@/path/to/photo.jpg' -F 'tags=dog,cat' http://jmathai.openphoto.me/photo/upload.json
curl -F 'photo=base64_encoded_string_representation_of_photo' -F 'title=My first day at work' http://jmathai.openphoto.me/photo/upload.json
#### PHP
$ch = curl_init('http://jmathai.openphoto.me/photo/upload.json');
curl_setopt(
$ch,
CURLOPT_POSTFIELDS,
array('photo' => '@/path/to/photo.jpg', 'tags' => 'dog,cat', returnOptions' => '300x300')
);
curl_exec($ch);
----------------------------------------
### Response
The response is in a standard [response envelope][Envelope].
* _message_, A string describing the result. Don't use this for anything but reading.
* _code_, _202_ on success
* _result_, A [Photo][Photo] object
#### Sample
{
"message":"Photo 8i uploaded successfully",
"code":202,
"result":{
"tags":[
"dog",
"cat"
],
"pathBase":"\/base\/201107\/1311053366-huge.jpg",
"appId":"opme",
"host":"testjmathai1.s3.amazonaws.com",
"dateUploadedMonth":"07",
"status":"1",
"hash":"6d7a9b0af31073a76ff2e79ee44b5c4951671fa2",
"width":"4288",
"dateTakenMonth":"07",
"dateTakenDay":"03",
"permission":"0",
"pathOriginal":"\/original\/201107\/1311053366-huge.jpg",
"exifCameraMake":"NIKON CORPORATION",
"size":"5595",
"dateTaken":"1309707719",
"height":"2848",
"views":"0",
"dateUploadedYear":"2011",
"dateTakenYear":"2011",
"creativeCommons":"BY-NC",
"dateUploadedDay":"18",
"dateUploaded":"1311053403",
"exifCameraModel":"NIKON D90",
"longitude":"-89.24",
"latitude":"37.65",
"path300x300":"\/custom\/201107\/1311053366-huge_300x300.jpg",
"id":"8i",
"requestedUrl":"\/custom\/201107\/1311053366-huge_300x300.jpg"
}
}
[Envelope]: api/Envelope.markdown
[Photo]: https://github.com/openphoto/frontend/blob/master/documentation/schemas/Photo.markdown
[purpose]: #purpose
[endpoint]: #endpoint
[parameters]: #parameters
[examples]: #examples
[example-curl]: #example-curl
[example-php]: #example-php
[response]: #response
[sample]: #sample