Is there a way to create a subdirectory in the default upload location on the server for the file plugin?
I've been at this for a bit. Below is the latest iteration.
I'm just attempting to create a sub directory in my default location on the server. The purpose is to create a preferences area that holds these values, as well as config stuff.
I've executed mkdir, createNewFile, remoteFile, etc.
I do get this error on the last bit of code:
Creating a new remote file is not allowed, you can only upload to a specific location using the plugins.file.streamToServer() method
Is this possible, or must the directories first exist in the upload location?
thanks,
--Joe.
- Code: Select all
var defaultLoc = plugins.file.getDefaultUploadLocation();
var success = true;
var fileName = newValue+'STSTestWriteFile.txt';
var folder = plugins.file.convertToRemoteJSFile('/reports/STSTESTWriteFile.txt');
if (!folder.exists()){
var response = globals.DIALOGS.showErrorDialog('Directory does not exist','Create subdirectory in upload location?',['Yes','No']);
if (response == "Yes"){
var cmd = 'mkdir '+defaultLoc+''+newValue;
cmd = cmd.replace('/','\\');
var cmdResponse = plugins.UserManager.Server().executeCommand(cmd);
//var newfileObj = plugins.file.convertToRemoteJSFile(newValue);
//success = newfileObj.createNewFile();
//if (success){
// var newFileObj = plugins.file.convertToRemoteJSFile(fileName);
// success = newFileObj.createNewFile();
// if (success){
// success = newFileObj.deleteFile();
// }
//
//}
} else {
success = false;
}
}