Downloading

Downloading the contents of a document

To request the contents of a document, issue the following GET request:

GET /api/documents/{documentId}/content

Where:

  • documentId: the ID of the document to get the contents of

Alternatively you can follow the Content property on the document via document.Links.Content.

The entire contents of the document are returned in the body as binary data. The headers provide additional information about the contents.

Some of the useful headers returned with the content include:

Content-Disposition: attachment; filename="Unity Forms - What's New.docx"; size=224348; filename*=utf-8''Unity%20Forms%20-%20What%27s%20New.docx
Content-Length: 224348
Content-Type: application/vnd.ms-word.document.12
Date: Fri, 08 Apr 2016 17:19:51 GMT

Downloading the thumbnail of a document

To request the thumbnail of a document, issue the following GET request:

GET /api/documents/{documentId}/thumbnail

Where:

  • documentId: the ID of the document to get the thumbnail of

The optional boolean parameter showNativeFormatAnnotations can be appended to the URL to toggle annotations displaying in the thumbnail. Currently the only annotations supported are comments within Microsoft Word documents. If this value is not provided it defaults to false.

The URL would look like the following:

https://app.sharebase.com/sharebaseapi/api/documents/12345/thumbnail?showNativeFormatAnnotations=true

The entire content of the document thumbnail is returned in the body as binary data. The header provides additional information about the thumbnail.

Content-Length: 11626
Content-Type: image/png

Different document types (such as image, text, Excel, PDF, PowerPoint, Word) along with video files are supported for getting a thumbnail. If an error prevents the thumbnail from being generated, a default image is returned as the thumbnail rather than an error code.

Downloading multiple items as a .zip file

Multiple items can be grouped together and downloaded as a .zip file with the following POST request:

POST /api/folders/zipcontent

With the following body:

{
    "ZipFileName":"MyZippedFiles",
    "DocumentIds": [
        113,
        114,
        160
    ],
    "FolderIds": [
        13,
        15,
        24
    ]
}

Where:

  • ZipFileName: a string used to name the .zip file, subject to Windows's restrictions on legal characters in a filename
  • DocumentIds: an array of document IDs, these are the documents to add to the .zip file
  • FolderIds: an array of folder IDs, these are the folders to add to the .zip file

The created .zip file is returned in the body as binary data. The headers provide additional information about the contents.

Some of the useful headers returned with the content include:

Content-Disposition: attachment; filename="MyZippedFiles.zip"; size=1427468; filename*=utf-8''MyZippedFiles.zip
Content-Length: 1427468
Content-Type: application/zip
Date: Fri, 24 Mar 2017 17:05:17 GMT

Warning

WARNING: Selecting multiple large documents to .zip can take a long time for ShareBase to process. When possible, it is recommended to store an already zipped folder as a document and download it as described above.