Uploads a photo owned by the current session user and returns the new photo. See photo uploads for a description of the upload workflow. The only storable values returned from this call are pid, aid, and owner. All applications can upload photos with a "pending" state, which means that the photos must be approved by the user before they are visible on the site. Photos uploaded by applications with the photo_upload extended permission will be visible immediately.
| Type | Name | Required | Description |
|---|---|---|---|
string
| api_key | ✔ | The application key associated with the calling application. |
string
| community | ✔ | Community system name. Use up.community.getList method to retrieve available communities. |
string
| session_key | ✔ | The session key of the logged in user. |
string
| sig | ✔ | An MD5 hash of the current request and your secret key, as described in the authentication guide. |
string
| format | Desired response format. Either XML (default) or JSON.
| |
int
| aid | The album id of the destination album. | |
string
| caption | The caption of the photo. | |
data
| data | ✔ | The raw image data for the photo. |
If no album is specified, the photo will be uploaded to a default album for the application, which will be created if necessary. Regular albums have a size limit of 60 photos. Default application albums have a size limit of 1000 photos.
Important: Upload requests must be formed as a MIME multipart message sent using POST data. Each argument, including the raw image data, should be specified as a separate chunk of form data.
The details of preparing a MIME multipart message depend on your particular request library, but typically the library will allow you to specify 'POST', set various MIME headers, then add additional data. The resulting MIME message should look like the following. Note that all line breaks in the message should be a carriage return followed by a newline ('\r\n') rather than just a newline ('\n'). For example, after specifying each Content-Disposition line, you should print '\r\n\r\n'.
Content-Type: multipart/form-data; boundary=SoMeTeXtWeWiLlNeVeRsEe MIME-version: 1.0 --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="method" up.photos.upload --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="api_key" 77a52842357422fadd912a2600e6e53c --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="community" mycommunity --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="session_key" 489727d0ab2efc6e8003018c-i2LLkn8BDb2s. --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="call_id" 1172623588.023010 --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="caption" Under the sunset --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="aid" 940915667462717 --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="sig" dfa724b8a5cd97d9df4baf2b60d3484c --SoMeTeXtWeWiLlNeVeRsEe Content-Disposition: form-data; name="data"; filename="somefilename.jpg" Content-Type: image/jpg [Raw file data here] --SoMeTeXtWeWiLlNeVeRsEe--
<?xml version="1.0" encoding="UTF-8"?> <photos_upload_response> <pid>940915697041656</pid> <aid>940915667462717</aid> <owner>219074</owner> <src>http://media.universalplatform.com/v67/161/72/219074/s219074_31637752_5455.jpg</src> <src_big>http://media.universalplatform.com/q34/161/72/219074/n219074_31637752_5455.jpg</src_big> <src_small>http://media.universalplatform.com/v67/161/72/219074/t219074_31637752_5455.jpg</src_small> <link>place link to photko here</link> <caption>After the sunrise</caption> </photos_upload_response>
| Code | Description |
|---|---|
| 1 | An unknown error occurred. Please resubmit the request. |
| 2 | The service is not available at this time. |
| 5 | The request came from a remote address not allowed by this application. |
| 100 | One of the parameters specified was missing or invalid. |
| 101 | The api key submitted is not associated with any known application. |
| 102 | The session key was improperly submitted or has reached its timeout. Direct the user to log in again to obtain another key. |
| 104 | Incorrect signature. |
| 120 | Invalid album id. |