2.7.2.8 HTML/Java Download Tool and API: Option with the Short Key

Upload tool that uses short key is available via the following URL:

https://thruservername/ExternalJavaDownload.aspx?ShortId=<shortIdValue>

Where shortIDValue is prepared in advance by the web service call

String GetDownloaderRequestKey (Guid SessionId, FTHDownloaderRequest request)

Which will be specified below and represents the following data structure:

FTHDownloaderRequest
    {
        public Guid SessionId,
        public int[] FileIds,
        public int[] FolderIds,
        public string SuccessUrl,
        public string ErrorReportingUrl
    }

Structure fields:

  • SessionId : identifier of the current session used for file download

  • FileIds (optional) – .array of integer values that hold IDs of files to download.

Note: multiple files will be zipped on download if HTML (non-Java) download is used.

  • FolderIds (optional) – array of integer values that hold IDs of folders to download.

Note: Folders will be zipped on download if HTML (non-Java) download is used.

  • SuccessUrl : Redirect browser window containing HTML download code or Java download applet to this URL if download is successful.

Page should be provided by the web application calling Thru API

  • ErrorReportingUrl : Redirect browser window containing HTML download code or Java download applet to this URL if download failed.

Page should be provided by the web application calling Thru API
If download failed, a server returns server error code (see below) using parameter “ThruErrorCode”.
If an error occurred and ErrorReportingUrl is not defined, then server throws unhandled exception in the upload page.
Error code is passed to error reporting page via ThruErrorCode URL parameter: ErrorReportingUrl?ThruErrorCode=<errorCode>
Note: the value of ErrorReportingUrl is not validated. Please ensure this is a valid URL.

Server error codes
The codes below are passed as a ThruErrorCode URL parameter to ErrorReportingUrl in case any error occurs as ErrorReportingUrl?ThruErrorCode=<errorCode>

0 Unknown error, information is not available.

1 SessionId is not a valid Guid variable.

2 Unknown SessionId. Supplied session identifier does not exist on the server

3 Array of FileId or FolderId contains an invalid ID integer value

4 Array of FileId or FolderId contains ID of the file or folder that does not exist

5 FileIds and FolderIds parameters are empty. Nothing to download

6 Download failed. This is generic error code returned for any unknown error in Download.

Sample File Upload API URL with short key:
https://test.thruinc.net/ExternalJavaDownload.aspx?ShortId=NKBJH4TMDJBK1P2W1Y9O

Sample steps to work with File Upload API URL with short key:
WDSL file for API version 4.0 is located at https://<servername>/ws4/fthservice.asmx?WSDL

  1. Get session id: 

Open() or OpenImmutable() or other Open* calls in Thru API

  1. Get FileId(s) or/and FolderId(s) of the files that will be downloaded by using one of the file browsing or search methods.

  2. Provide SuccessUrl and ErrorReportingUrl and fill in the structure 

FTHDownloaderRequest

  1. Generate short key* ShortIdValue= GetDownloaderRequestKey (Guid SessionId, FTHDownloaderRequest request)*

  2. Compose View URL and open browser window with the link: 

https://<serverName>/ExternalJavaDownload.aspx?ShortId=<ShortIdValue>

Reference: Data structure to create ShortID for Download

*FTHDownloaderRequest***

Data Type

Field Name

Sample Value

Comments

Guid

SessionId

189BA074-F668-49CC-B7F6-330F4F89D755

Session for file viewing

int[]

FolderIds

Array of folders ids

int[]

FileIds

Array of files ids

String

SuccessUrl

http://success.com

Success url

String

ErrorReportingUrl

http://error.com

Error url

Sample

<downloaderRequest><SessionId>310105b2-5d9c-437b-bbdc-be6651992ffb</SessionId><FileIds><int>1</int><int>2</int></FileIds><FolderIds><int>2</int><int>6</int></FolderIds><SuccessUrl>http://success.com</SuccessUrl><ErrorReportingUrl>http://error.com</ErrorReportingUrl></downloaderRequest>

Data Transfer Object

public class FTHDownloaderRequest
    {
        public Guid SessionId { get; set; }
        public int[] FileIds { get; set; }
        public int[] FolderIds { get; set; }
        public string SuccessUrl { get; set; }
        public string ErrorReportingUrl { get; set; }
    }

Reference: Method GetDownloaderRequestKey

Method

String GetDownloaderRequestKey (Guid SessionId, FTHDownloaderRequest request)

Description

The call accepts FTHDownloaderRequest object and returns shortID.

Request Body

FTHDownloaderRequest object

Return Data Object

string

Invocation Scenario(s)

Remarks