JavaPowUpload 2.2
Methods
  Home page
Contact support

JavaPowUpload object methods 

For more information on how to use JavaPowUpload methods see How to section.



clickBrowse method

clickDownload method

clickStop method

getFiles method

getItemById method

addFile method

removeFileById method

clearTree method

reloadTree method

getProgressInfo method

getParam method

getParamLong method

getParamBool method

setParam method

getLastServerResponse method

getLastStatusCode method

addPostField method

getPostField method

removePostFields method

toggleDetailsPanel method


browseFiles

void browseFiles()

Description

In upload mode, it shows the "Browse files" dialog. Selected files and folders will be added to the list. In download mode, it shows the "Choose destination folder" dialog. Files will be downloaded into the selected folder.

Example

JavaPowUpload.browseFiles();



startUpload

void startUpload()

void startDownload()

Description

The method starts upload or download process.

Example

JavaPowUpload.startUpload();



cancelUpload

void cancelUpload()

void cancelDownload()

Description

Cancels upload or download process.

Example

JavaPowUpload.clickStop();



getFiles

ArrayList getFiles()

Description

The method returns an ArrayList object that contains UploadItem or DownloadItem objects depending on which mode JavaPowUpload has been started in.

Example

var list = JavaPowUpload.getFiles();
for(i=list.size()-1;i>=0;i--)
{
 if(list.get(i).isFile())
  alert(list.get(i).getFullPath());
}


getItemById

ListItem getItemById(String id)

ListItem getItemByPath(String filePath)

ListItem getItem(int index)

Description

The method returns UploadItem or DownloadItem object depending on which mode JavaPowUpload has been started in.
It's recommended to use getItemById method to get needed instance of UploadItem (DownloadItem) object.

Parameters


id
- Unique identifier of file.
filePath - Path to a file in the tree.
index - Index of an item.

Example

//get item by id
var file = JavaPowUpload.getItemById(uniqueIdentifier);

//get item by path
var file = JavaPowUpload.getItemByPath('\folder\file.txt');

//get item by index
var file = JavaPowUpload.getItem(0);

addFile

void addFile(String filePath, String url, String thumbnailUrl, String length, String id, String uncompress, String delete, String secription)

void addFile(String filePath, String url, String length, String id, String uncompress, String delete, String secription)

void addFile(String filePath, String url, String length, String id, String uncompress, String delete)

void addFile(String filePath, String url, String length, String id, String uncompress)

void addFile(String filePath, String url, String length, String id)

void addFile(String filePath, String url, String length)

void addFile(String filePath, String url)

 

Description

Adds file for download. This function does not work in upload mode for security reasons.

Parameters

filePath - Path of a file in the tree. If some folders do not exist in the tree, they will be created.
url - HTTP or FTP url to the file.
thumbnailUrl - HTTP url to samll sized copy of image (thumbnail).
length - Size of file.
id - File id.
uncompress - Uncompresses zip file after downloading or not. "true" or "false".
delete - Deletes zip file after extracting or not. "true" or "false".
Description - File description text. It is displayed in the file tree.

Example

JavaPowUpload.addFile("SomeFolder\\testFile.txt","http://somedomain.com/downloads/file.txt","1024","123","false","false");

removeFileById

void removeFileById(String id)

void removeFile(Long index)

void removeFile(String filePath)

Description

Removes file from list .
It's recommended to use removeFileById method to remove needed instance of UploadItem (DownloadItem) object.

Parameters


id - Unique identifier of file.

index - A number that indicates the 0-based index of the file in the list. The value must be greater than or equal to 0 and less than JavaPowUpload.getFiles().size()

filePath - Path to a file in the tree.

Example

JavaPowUpload.removeFileById(file.getId());

clearTree

void clearTree()

Description

The method removes all files from the tree.

Example

JavaPowUpload.clearTree();



reloadTree

void reloadTree()

Description

The method reloads the upload tree from the current source (html parameters or xml file). It works only in download mode.

Example

JavaPowUpload.reloadTree();



getProgressInfo

ProgressInfo getProgressInfo()

Description

Returns an instance of the ProgressInfo class.

Example

var progress = JavaPowUpload.getProgressInfo();



getParam

String getParam(String paramName)

Description

Returns the value of the specified parameter.

Parameters

paramName - Name of a parameter the value of which should be returned.

Example

var uploadUrl = JavaPowUpload.getParam("Upload.UploadUrl");



getParamLong

long getParamLong(String paramName)

Description

Returns a long representation of the specified parameter value. If the value cannot be converted to long, it returns 0.

Parameters

paramNameName of a parameter the value of which should be returned.

Example

var fontSize = JavaPowUpload.getParamLong("Common.DetailsArea.FileDetails.FontSize");


getParamBool

boolean getParamBoolg(String paramName)

Description

Returns a boolean representation of the specified parameter value. If the value cannot be converted to boolean, it returns false.

Parameters

paramName - Name of a parameter the value of which should be returned.

Example

var buttonVisible = JavaPowUpload.getParamBool("Common.ProgressArea.DownloadButton.Visible");



setParam

void setParam(String paramName, String paramValue)

Description

The method sets a value of the specified in paramName parameter to paramValue.

Example

JavaPowUpload.setParam("Upload.UploadUrl","http://localhost/JavaPowUpload/uploadfiles.php");



getLastServerResponse

String getLastServerResponse()

Description

Returns last server reply as a string. This function returns non-empty value only when JavaPowUpload has been started in HTTP upload mode.

Example

window.alert(JavaPowUpload.getLastServerResponse());



getLastStatusCode

long getLastStatusCode ()

Description

HTTP code of server reply. 200 in most cases means success, 500 Internal error. You can find most HTTP errors with short descriptions at w3.org website.

Example

window.alert(JavaPowUpload.getLastStatusCode());



addPostField

void addPostField(String name, String value)

Description

Adds name–value pair to the list that will be sent as text Form items. Actually this method appends "name=value" string to the end of the Upload.HttpUpload.CustomPostFields parameter.

Parameters

name - Name of a text Form item. It is similar to HTML "Name" parameter of the Form item.

value - Value of a text Form item. It is similar to HTML "Value" parameter of the Form item.

Example

JavaPowUpload.addPostField("Username","JDoe");

 

getPostField

void getPostField(String name)

Description

Returns a value of a form field with the specified name.

Parameters

name - Name of a text Form item. It is similar to HTML "Name" parameter of the Form item.

Example

window.alert(JavaPowUpload.getPostField("Username"));

 

removePostFields

void removePostFields()

Description

Removes all text Form items added before. Actually this method clears a value of Upload.HttpUpload.CustomPostFields parameter.

Example

JavaPowUpload.removePostFields();

 

toggleDetailsPanel

void toggleDetailsPanel()

Description

Show/hide DetailsArea

Example

JavaPowUpload.toggleDetailsPanel();