Make directory in plugins.file default location RESOLVED

Questions and answers on developing, deploying and using plugins and JavaBeans

Make directory in plugins.file default location RESOLVED

Postby joe26 » Tue Jun 19, 2018 11:31 pm

Hi again..

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?


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;
Last edited by joe26 on Wed Jun 20, 2018 4:22 am, edited 1 time in total.
Posts: 80
Joined: Wed Jun 19, 2013 10:30 pm

Re: Make directory in plugins.file default location RESOLVED

Postby joe26 » Wed Jun 20, 2018 4:21 am

Mostly sussed this stuff out...

Need to create a file, stream it to the server with a directory name.
The directory name will auto create.
And, maybe, delete the file.

The Kabuki Dance:
Code: Select all
   defaultLoc = plugins.file.getDefaultUploadLocation();
   fileName = 'STSTestWriteFile.txt';
   fileNamePath = '/temp/'+fileName;//local directory
   fileObj = plugins.file.createFile(fileNamePath);
   consolePath = '/consoleStuff/'+fileName;//remote directory under defaultLocation
   var item = plugins.file.convertToRemoteJSFile('/consoleStuff/STSTestWriteFile.txt');

Posts: 80
Joined: Wed Jun 19, 2013 10:30 pm

Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 4 guests