Community articleDownloading a file
Added by IBM contributorIBM on March 24, 2014
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Download a file from your library programmatically.



Download a file from your library programmatically.

See Authenticating requests for information about how to authenticate the request.

You can use one or more of these headers.

You can use one or more of these input parameters. Separate multiple parameters with an ampersand (&).

Input

None.

Output

Binary content of the file. If active content filtering is enabled, and the file is an HTML file, it is filtered.

Note: This API can return a HTTP1.1/ 302 redirect if a different download domain is configured. When a different download domain is configured, the client needs be able to follow the redirect to eventually download the file.

Input
Method URI Description
GET /files/basic/anonymous/api/document/{document-id}/media Returns a public file from your library without authenticating the request.
GET /files/basic/api/myuserlibrary/document/{document-id}/media
Determine the resource address in either of the following ways:
Value of the href attribute of the <link rel="edit-media"> element in the file's Document Atom entries.
Construct the address using the following URL:/basic/api/myuserlibrary/document/{document-id}/ where {document-id} is the <td:uuid> or <td:label> element of the document entry.
Returns a file from your library. This request requires authentication.
Note: Use this URI to retrieve the binary data if you plan to update and return it using a PUT request.
Name Type Optional Description
document-id
string No {document-id} is the <td:uuid> or <td:label> element of the document entry.
Name Type Optional Description
identifier
string Yes String. Indicates the identifier used in the document segment of the web address. Options are uuid or label. Uses the UUID as the identifier by default.
inline
boolean Yes Specifies whether the documents contents should be included inline in the content element. Options are true or false.
logDownload
boolean Yes Specifies whether to log this file download. Options are true or false. By default, it does log the download.
Name Type Optional Description
If-Modified-Since
string Yes Used to validate the local cache of the feed and entry documents retrieved previously. If the feed or entry has not been modified since the specified date, HTTP response code 304 (Not Modified) is returned.
If-None-Match
string Yes Contains an ETag response header sent by the server in a previous request to the same URL. If the ETag is still valid for the specified resource, HTTP response code 304 (Not Modified) is returned.
Output
Content Type: text/html
Code Description
200
Indicates that the file entry was successfully downloaded. If an error occurs, this header contains one of the error codes.
401
Unauthorized.
403
Forbidden.
404
Not Found.
References