Share:

PREVIOUS  |  NEXT

Local File Management Scripting Resources


Workflow provides the following methods in the resp.storage namespace that enable you to perform actions on Local File Management files and folders in scripting.

//Save a new file to the local storage
public ScriptFile saveFile(ScriptFile file, String path);

//Get a file from local storage
public ScriptFile getFile(String path);

//Get all files from a folder
public List getFiles(String path);

//Delete a file
public boolean deleteFile(String path);

//Delete a folder
public boolean deleteFolder(String path);

//Replace a file
public ScriptFile replaceFile(ScriptFile file, String path);

//Create a new folder
public ScriptFile newFolder(String name, String path);

//Get the URL of a file
public String getLink(ScriptFile file);


See the following code samples for how to use the above methods: 

//Get files from myFolder
def files = resp.storage.getFiles('/app/myFolder');

//Create and save new file, then get the file
def file = resp.newFile("newFile.txt", "Test file example");
resp.storage.saveFile(file, "/app/myFolder");
file = resp.storage.getFile('/app/myFolder/newFile.txt');

//Delete a file
logger.debug('File', resp.storage.deleteFile('/app/myFolder/newFile.txt'));

//Create a new folder, then delete the folder
resp.storage.newFolder('newFolder', '/app');
resp.storage.deleteFolder('/app/newFolder');

//Get a file, then get a link for the file
def file = resp.storage.getFile('/app/Happy.png')
logger.debug('Link', resp.storage.getLink(file));

//Create new file, save the file, update and then replace the file
def file = resp.newFile("newFile.txt", "Test file example");
resp.storage.saveFile(file, "/app/myFolder");
def updatedFile = resp.newFile("newFile.txt", "Test updated file example");
resp.storage.replaceFile(file, "/app/myFolder")