Skip to content

Media Manipulation

Hongsuda edited this page Aug 20, 2015 · 2 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 media data (i.e. image, audio, video, and document objects that are part of the survey response). This can be made with a HTTP GET or POST call.

URI

media/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 hashed password for the above user.

Additional Parameters

  • (r) client = A short description of the software client performing the upload.
  • (r) id = The uuid of the media being requested.
  • (o) size = Used for retrieving different versions of images. Valid values are: original, small, and icon. If this parameter is provided, the system assumes that the media type is the image. Supplying this parameter for other media types will result in a media not found error.

Example POST

POST /app/media/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
  &size=icon

cURL Example

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

Output Format

Success

The requested media file is returned in the HTTP stream.

Failure

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

↑ Back to Top