|
JavaPowUpload 2.1
Methods |
Home
page Contact
support
|
JavaPowUpload object methods
For more information on how to use JavaPowUpload methods see How to section.
browseFiles
void browseFiles()
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.
JavaPowUpload.browseFiles();
startUpload
void startUpload()
void startDownload()
The method starts upload or download process.
JavaPowUpload.startUpload();
cancelUpload
void cancelUpload()
void cancelDownload()
Cancels upload or download process.
JavaPowUpload.clickStop();
getFiles
ArrayList getFiles()
The method returns an ArrayList object that contains UploadItem or DownloadItem objects depending on which mode JavaPowUpload has been started in.
getItemById
ListItem getItemById(String id)
ListItem getItemByPath(String filePath)
ListItem getItem(int index)
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.
id
- Unique identifier of file.
filePath - Path to a file in the tree.
index - Index of an item.
//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 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)
Adds file for download. This function does not work in upload mode for security reasons.
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.
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.
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)
Removes file from list .
It's recommended to use removeFileById method to remove needed instance of UploadItem (DownloadItem) object.
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.
JavaPowUpload.removeFileById(file.getId());
clearTree
void clearTree()
The method removes all files from the tree.
JavaPowUpload.clearTree();
reloadTree
void reloadTree()
The method reloads the upload tree from the current source (html parameters or xml file). It works only in download mode.
JavaPowUpload.reloadTree();
getProgressInfo
ProgressInfo getProgressInfo()
Returns an instance of the ProgressInfo class.
var progress = JavaPowUpload.getProgressInfo();
getParam
String getParam(String paramName)
Returns the value of the specified parameter.
paramName - Name of a parameter the value of which should be returned.
var uploadUrl = JavaPowUpload.getParam("Upload.UploadUrl");
getParamLong
long getParamLong(String paramName)
Returns a long representation of the specified parameter value. If the value cannot be converted to long, it returns 0.
paramName - Name of a parameter the value of which should be returned.
var fontSize = JavaPowUpload.getParamLong("Common.DetailsArea.FileDetails.FontSize");
getParamBool
boolean getParamBoolg(String paramName)
Returns a boolean representation of the specified parameter value. If the value cannot be converted to boolean, it returns false.
paramName - Name of a parameter the value of which should be returned.
var buttonVisible = JavaPowUpload.getParamBool("Common.ProgressArea.DownloadButton.Visible");
setParam
void setParam(String paramName, String paramValue)
The method sets a value of the specified in paramName parameter to paramValue.
JavaPowUpload.setParam("Upload.UploadUrl","http://localhost/JavaPowUpload/uploadfiles.php");
getLastServerResponse
String getLastServerResponse()
Returns last server reply as a string. This function returns non-empty value only when JavaPowUpload has been started in HTTP upload mode.
window.alert(JavaPowUpload.getLastServerResponse());
getLastStatusCode
long getLastStatusCode ()
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.
window.alert(JavaPowUpload.getLastStatusCode());
addPostField
void addPostField(String name, String value)
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.
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.
JavaPowUpload.addPostField("Username","JDoe");
getPostField
void getPostField(String name)
Returns a value of a form field with the specified name.
name - Name of a text Form item. It is similar to HTML "Name" parameter of the Form item.
window.alert(JavaPowUpload.getPostField("Username"));
removePostFields
void removePostFields()
Removes all text Form items added before. Actually this method clears a value of Upload.HttpUpload.CustomPostFields parameter.
JavaPowUpload.removePostFields();
toggleDetailsPanel
void toggleDetailsPanel()
Show/hide DetailsArea
JavaPowUpload.toggleDetailsPanel();