2.7.1.8 Upload HTML5/HTML4/Java Tool and API : Option with the Short Key
Upload tool that uses short key is available via the following URL:
https://thruservername/ExternalJavaUpload.aspx?ShortId=<shortIdValue>
Where shortIDValue is prepared in advance by the web service call
String GetUploaderRequestKey(Guid sessionId, FTHUploaderRequest request)
Which will be specified below and represents the following data structure:
FTHUploaderRequest
{
public Guid SessionId,
public int FolderId,
public string SuccessUrl,
public string ErrorReportingUrl,
public string FileFilter,
public string FileFilterExceptions
}
Structure fields:
SessionId : identifier of the current session used for file upload
FolderId: ID of a folder in Thru file system obtained by previous web service calls. Files will be uploaded to this folder.
SuccessUrl : Redirect browser window containing HTML upload code or Java upload applet to this URL if upload is successful. Page should be provided by the web application calling Thru API
ErrorReportingUrl : Redirect browser window containing HTML upload code or Java upload applet to this URL if upload failed.
Page should be provided by the web application calling Thru API
If upload 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.
FileFilter : specifies which file types can be uploaded via Java applet
Format: <Description> : <extension1>, <extension2> … <extensionN>.
Example: FileFilter=“Zip files (*.zip, *.7z, *.tar): zip, 7z, tar” will allow upload of files with zip, 7z, tar extensions.
Browsing in Add button is allowed only to the files of specified type. Drag and drop for all other file types is ignored.
If parameter is not specified, all file types can be uploaded.
FileFilterExceptions : FileFilterExceptions [optional] : specifies which file types cannot be uploaded via Java applet. Format:
<extension1>, <extensionX>.
Example: FileFilterExceptions=exe,msi,mp3 will prevent uploading of the file types exe, msi, mp3.
Note: Parameters FileFilter and FileFilterExceptions are mutually exclusive, only one can be used on java upload URL.
If the same file extension is specified in FileFilter and FileFilterExceptions, the latter overrides the former.
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 FolderId is not a valid integer variable
3 Unknown SessionId. Supplied session identifier does not exist on the server
4 Folder with specified ID does not exist on the server.
5 Upload failed. This is generic error code returned for any unknown error in upload. Please check event log on the server running Thru server software.
Sample File Upload API URL with short key:
https://test.thruinc.net/ExternalJavaUpload.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
Get session id:
Open() or OpenImmutable() or other Open* calls in Thru API
Get FolderID for target upload folder by using one of the file browsing or search methods.
Provide SuccessUrl, ErrorReportingUrl, FileFilter or FileFilterExceptions and fill in the structure
FTHUploaderRequest
Generate short key
ShortIdValue= GetUploaderRequestKey(Guid sessionId, FTHUploaderRequest request)
Compose View URL and open browser window with the link:
https://<serverName>/ExternalJavaUpload.aspx?ShortId=<ShortIdValue>
Reference: Data structure to create ShortID for Upload
FTHUploaderRequest
Data Type | Field Name | Sample Value | Comments |
---|---|---|---|
Guid | SessionId | 189BA074-F668-49CC-B7F6-330F4F89D755 | identifier of the current session used for file upload |
int | FolderId | 6 | Target FolderId. Files will be uploaded to this folder. |
string | FileFilter | Zip files (*.zip, *.7z, *.tar): zip, 7z, tar | string for file filtering used in file open dialog. Defines allowed types. |
String | FileFilterExceptions | exe, com, bat | string for file filtering used in file open dialog. Defines restricted types. String format: |
string | SuccessUrl | Upload API page redirects to this URL if upload succeeded | |
String | ErrorReportingUrl | Upload API page redirects to this URL if upload failed |
Sample
<uploaderRequest><SessionId>310105b2-5d9c-437b-bbdc-be6651992ffb</SessionId><FolderId>6</FolderId><SuccessUrl>http://success.com</SuccessUrl><ErrorReportingUrl>http://error.com</ErrorReportingUrl><FileFilter>Zip files (*.zip, *.7z, *.tar): zip, 7z, tar</FileFilter><FileFilterExceptions>exe, com, bat</FileFilterExceptions></uploaderRequest>
Data Transfer Object
public class FTHUploaderRequest
{
public Guid SessionId { get; set; }
public int FolderId { get; set; }
public string SuccessUrl { get; set; }
public string ErrorReportingUrl { get; set; }
public string FileFilter { get; set; }
public string FileFilterExceptions { get; set; }
}
Reference: Method GetUploaderRequestKey
Method | String GetUploaderRequestKey (Guid SessionId, FTHUploaderRequest request) |
---|---|
Description | The call accepts FTHUploaderRequest object and returns shortID. |
Request Body | FTHUploaderRequest object |
Return Data Object | string |
Invocation Scenario(s) | |
Remarks |