qie.newNetFile¶
Signature: qie.newNetFile(filepath, domainUsername, password, parameters*, autoClose*)
Returns: NetFile netFile - a new NetFile instance
Creates a new com.qvera.qie.utils.NetFile object to work with network share files. This creates a new instance of NetFile that can be used with deleteFile, moveFile, readFile and writeFile functions.
For more information on NetFile See this KB article.
Note
Use for network share file manipulation that can not be accessed through the local system account the QIE service runs under.
Note
QIE uses version 2.1.10 of jcifs-ng. (See this KB article for more information.
Note
This implementation of NetFile supports the following SMB versions. Full support: SMB1, SMB202, SMB210. Limited support (no encryption): SMB300, SMB302, and SMB311.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | filepath | the file path | |
| String | domainUsername | the domain and username to the network share separated by a ';'. For example [domain;]username. | |
| String | password | the password to the network share | |
| String | parameters* | (optional) network share configuration parameters to be used by this connection. (Format: {key}={value}\n{key2}={value2}...) | null |
| Boolean | autoClose* | (optional) auto close NetFile after 5 minutes (Note When setting this to false you will want to call the netFile.close() method manually to prevent memory leaks) | true |
Example¶
// Create a NetFile for accessing a remote SMB network share
var newNetFile = qie.newNetFile(
'//test-smb-dc1/test-share/aPath/mine.txt', // filepath: //<server>/<share>/<path>/<filename>
'testsmb.corp.qvera.com;testnetshareuser', // domainUsername: domain;username (domain is optional)
'testPassword', // password: network share password
'file_mode=0777\ndir_mode=0777', // parameters (optional): key=value pairs separated by newlines
false // autoClose (optional, default=true): false = caller must call close()
);
// Write data to the remote file (append = true)
qie.writeFile(newNetFile, 'This is a remote file.', true);
// IMPORTANT:
// If autoClose is set to false, you MUST manually close the NetFile
// to prevent resource/memory leaks.
newNetFile.close();