Preview a File from a Public Share (REST API: GET)

Updated

This operation allows you to preview a backed up file from a public share.

Preview is currently supported for all images and Microsoft Office file types.

By default, you can preview files that have a maximum file size limit of 10 MB. For instructions on changing the file size limit, see Changing the File Size Limit for Preview.

Request

Syntax

GET <webservice>/publicshare/{shareId}/action/preview?path={path} HTTP/1.1

Host: <host name>

Accept: application/html

where <webservice> is the root path used to route the API requests to the Web Server.

For more information, see Available Web Services for REST API.

Request Parameters

Name

Description

Required

shareId

The unique identifier (syncWebFolderId response) returned when you share a file or folder or view the shared files and folders. If the shareId is not known, see View Shared Files and Folders to retrieve it.

Yes

path

The path to the shared file that you want to download. Specify the path relative from the share root.

Note: The path must be URL encoded before they are sent in the request.

Yes

Request Headers

Name

Description

Host

The host name of the Web Server or Web Console used in the API request.

Accept

The format of the response. Valid values are text/html for non-images or image/jpeg for images.

Response

All image file types are previewed as .jpg files.

For Microsoft office files, the HTML content of the file is displayed as preview.

Examples

Sample Request

GET <webservice>/drive/publicshare/582810/action/preview?path=\DemoFile1.doc HTTP/1.1

Host: <host name>

Accept: text/html

Sample Response

<html xmlns="http://www.w3.org/1997/xhtml">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<head>

<meta name="X-Parsed-By" content="org.apache.tika.parser.DefaultParser"/>

<meta name="X-Parsed-By" content="org.apache.tika.parser.txt.TXTParser"/>

<meta name="Content-Encoding" content="ISO-8859-1"/>

<meta name="ext_name" content="tmp"/>

<meta name="Content-Type" content="text/plain; charset=ISO-8859-2"/>

</head>

<body style="background:#fff;" background="" >

<pre>Demo File Content</pre>

</body>

</html>

Supported Error Codes

Code

Status

Description

400

Bad Request

The request is missing required parameters or the file name has some unacceptable characters.

204

No Content

Preview is not available for the file.

403

Forbidden

User does not have permissions to preview or the preview is requested for a folder or an unsupported file type.

404

Not Found

The specified file does not exist.