4.4 KiB
4.4 KiB
Open Photo API / Photo Upload
OpenPhoto, a photo service for the masses
Purpose of the Photo Upload API
This API is used to upload a new photo for a user.
Endpoint and parameters
Authentication: required
POST /photo/upload.json
- 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
- tags (optional), i.e. dog,cat - A comma delimited string of alpha numeric strings.
- latitude (optional), i.e. 34.76 - A decimal representation of latitude.
- longitude (optional), i.e. -87.45 - A decimal representation of longitude.
- 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)
Example
Command line curl
curl -F 'photo=@/path/to/photo.jpg' -F 'tags=dog,cat' 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 a Photo object.
{
"message":"Photo 8i uploaded successfully",
"code":200,
"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"
}
}
Specification
Content type multipart/formdata
Preferred. You can post to this API using multipart/formdata.
POST /photo/upload.json HTTP/1.1
Host: jmathai.openphoto.me
Content-Type: multipart/form-data; boundary=----------------SOMERANDOMSEPARATOR
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="tags"
disneyland,epcotcenter
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="longitude"
123.456
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="latitude"
135.246
-----------------------------SOMERANDOMSEPARATOR
Content-Disposition: form-data; name="photo";
filename="/path/to/your/photo.jpg"
Content-Type: image/gif
{your_binary_content_here}
-----------------------------SOMERANDOMSEPARATOR--
Content type application/x-www-form-urlencoded
You can post to this API using application/x-www-form-urlencoded and base64 encoding the photo.
POST /photo/upload.json HTTP/1.1
Host: jmathai.openphoto.me
photo=base64_encoded_string_representation_of_your_photo