Skip to content

Image Manipulation

Steve Nolen edited this page May 1, 2015 · 13 revisions

All of the media objects (i.e. image, audio, video, document) have the same access rules, but the data returned will vary from API to API.

Operation Participant Author Analyst Supervisor
Read Their Own Private or Shared Media Objects anytime N/A N/A N/A
Read Someone Else's Shared Media Objects never anytime if the campaign is shared anytime
Read Someone Else's Private Media Objects never never never anytime

What does it do?

Allows users to read image data. This can be made with a HTTP GET or POST call.

URI

image/read

Input Parameters

Supports Token-Based Authentication ...

  • (r) auth_token = A valid authentication token from user/auth_token. May also be set using the Set-Cookie header.

... or User-Password Authentication

  • (r) user = A username of the user attempting to login
  • (r) password = A password for the above user.

Additional Parameters

  • (r) client = A short description of the software client performing the upload.
  • (r) id = The id of the image being requested.
  • (o) size = Used for retrieving other versions of images. Valid values are: original, small, and icon.

Example POST

POST /app/image/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=0ec4dac0-5293-11e1-a8e1-c82a142568c4
  &client=curl
  &id=1c99b4cc-5293-11e1-a501-c82a142568c4

cURL Example

curl -v "http://localhost:8080/app/image/read?client=curl&id=bea5a419-8a23-4f8a-a501-07b5dc863a69&auth_token=22283b32-f2af-442b-808e-17a830cca00c" > kitty.jpg

Output Format

Success

The requested image is returned in the HTTP stream.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top

What does it do?

Allows users to read image data.

URI

image/batch/[type/]read

Types

The result will always be a single object that contains all of the information for all of the images. Below is the list of different types that are supported.

Type Description
zip Returns a .zip file that contains all of the images compressed into a single file.

Input Parameters

Supports Token-Based Authentication ...

  • (r) auth_token = A valid authentication token from user/auth_token. May also be set using the Set-Cookie header.

... or User-Password Authentication

  • (r) user = A username of the user attempting to login
  • (r) password = A password for the above user.

Additional Parameters

  • (r) campaign_urn = A valid campaign URN for the currently logged in user.
  • (r) client = The name of the software client accessing the API.
  • (r) user_list = A comma separated list of usernames that must be valid for the campaign being queried. urn:ohmage:special:all is also allowed.
  • (o) survey_id_list = Optional, but must be present if prompt_id_list is not present. A comma separated list of survey ids which must exist in the campaign being queried. urn:ohamge:special:all is also allowed.
  • (o) prompt_id_list = Optional, but must be present if survey_id_list is not present. A comma separated list of prompt ids which must exist in the campaign being queried. urn:ohamge:special:all is also allowed.
  • (o) privacy_state = If present, must be one of "private" or "shared". The output is dependent on the access-control rules governing the role of the logged-in user.
  • (o) start_date = Optional, but must be present if end_date is present: allows querying against a date range.
  • (o) end_date = Must be present if start_date is present; allows querying against a date range
  • (o) survey_response_id_list = A comma-separated list of survey response IDs. The results will only be of survey responses whose ID is in this list.

Example POST

POST /app/image/batch/zip/read HTTP/1.1
 Host: dev.ohmage.org
 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7
 Content-Length: byte-length-of-content
 Content-Type: application/x-www-form-urlencoded

  auth_token=0ec4dac0-5293-11e1-a8e1-c82a142568c4
  &client=curl
  &campaign_urn=urn:campaign:va:ptsd:beta
  &user_list=urn:ohmage:special:all
  &survey_id_list=urn:ohmage:special:all

cURL Example

curl -v "http://localhost:8080/app/image/batch/zip/read?campaign_urn=urn:campaign:ucla:test&client=curl&auth_token=22283b32-f2af-442b-808e-17a830cca00c&user_list=urn:ohmage:special:all&survey_id_list=urn:ohmage:special:all" >images.zip

Output Format

Success

A ZIP file is returned.

Failure

See the error page for a description of error codes and their associated descriptions.

↑ Back to Top