Class Accessor.File
A class which provides functionality for working with files. Use
HTTPFabricConnection#createFilespaceAccessor to create a
new accessor.
Defined in: <D:\Programs\Neeve\Projects\NeeveBuild16\stjsapi/src/main/webapp/js\accessor\File.js>.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
Accessor.File(fabricConnection)
Creates a filespace accessor for getting base64 content of files and raising
file events
|
| Method Attributes | Method Name and Description |
|---|---|
| void |
getAsBinaryContent(formName, callback)
Asynchronously posts the file selected by a user in the form with the
specified
formName. |
| void |
raiseAsBytesEvent(formName, eventId, scope, callback)
Asynchronously posts the file selected by a user in the form with the
specified
formName. |
| void |
uploadAsFile(formName, path, callback)
Asynchronously posts the file selected by a user in the form with the
specified
formName.The file data is being saved in folder specified
Result string is passed to callback function when returned from server side. |
Class Detail
Accessor.File(fabricConnection)
Creates a filespace accessor for getting base64 content of files and raising
file events
- Parameters:
- {HTTPFabricConnection} fabricConnection
- The connection for which this filespace accessor is created
Method Detail
getAsBinaryContent(formName, callback)
Asynchronously posts the file selected by a user in the form with the
specified
The html-page should contain the form like the following.
formName. The file data is base64-encoded on the
server side and returned back. It is passed to the specified
callback function when returned from server side.The html-page should contain the form like the following.
<form name="exampleUploadForm" enctype="multipart/form-data"> <input type="file" name="exampleFile"> </form>The javascript code for getting file base64 content for this example is the following.
var exampleCallback = function(fileBase64Data)
{
doSomething(fileBase64Data);
}
var connection = new HTTPFabricConnection(user, password);
var accessor = connection.getFileSpaceAccessor();
accessor.getAsBinaryContent('exampleUploadForm', exampleCallback);
- Parameters:
- {String} formName
- The name of the file upload html-form
- {Function} callback
- The callback function called with the server response containing base64-encoded data of the file selected by user.
raiseAsBytesEvent(formName, eventId, scope, callback)
Asynchronously posts the file selected by a user in the form with the
specified
The html-page should contain the form like the following.
formName. The file data is is converted to bytes event and sent with a scope specified.
Result string is passed to callback function when returned from server side.The html-page should contain the form like the following.
<form name="exampleUploadForm" enctype="multipart/form-data"> <input type="file" name="exampleFile"> </form>The javascript code for raising bytes event from file example is the following.
var exampleCallback = function(returnedData)
{
doSomething(returnedData);
}
var connection = new HTTPFabricConnection(user, password);
var accessor = connection.getFileSpaceAccessor();
accessor.raiseAsBytesEvent('exampleUploadForm', 'eventId', 'scope', exampleCallback);
- Parameters:
- {String} formName
- The name of the file upload html-form
- {String} eventId
- eventId to use for raised event (event prototype should exist)
- {String} scope
- scope to use for raised event (INHERITED, OBSERVABLE, GLOBAL)
- {Function} callback
- The callback function called with the server response containing OK or NOK message.
uploadAsFile(formName, path, callback)
Asynchronously posts the file selected by a user in the form with the
specified
The html-page should contain the form like the following.
formName.The file data is being saved in folder specified
Result string is passed to callback function when returned from server side.The html-page should contain the form like the following.
<form name="exampleUploadForm" enctype="multipart/form-data"> <input type="file" name="exampleFile"> </form>The javascript code for saving file for this example is the following.
var exampleCallback = function(returnedData)
{
doSomething(returnedData);
}
var connection = new HTTPFabricConnection(user, password);
var accessor = connection.getFileSpaceAccessor();
accessor.uploadAsFile('exampleUploadForm', 'path', exampleCallback);
- Parameters:
- {String} formName
- The name of the file upload html-form
- {String} path
- Path to upload the file to. Exception will be thrown in case of incorrect path.
- {Function} callback
- The callback function called with the server response containing OK or NOK message.