The ClientFile component is used to manage files on the server that hosts the Oracle BPM WorkSpace application. The ClientFile component can rename, move, copy, and delete files. In addition, the ClientFile component is used to transfer files between the server that hosts the WorkSpace application and the machine on which the participant is browsing.
Uploads are file transfers from the server that hosts Oracle BPM WorkSpace to the machine on which the participant is browsing. In this example, c:\tmp\clientFile is on the machine on which the participant is browsing.
myBinContent = Binary(text : "Test message to upload as binary",
encoding : "UTF8")
myClientFile = ClientFile(sourcePath : "C:/tmp/clientFile")
clientFileBName = uploadTo(myClientFile, fromBinary : myBinContent,
message : "From Binary")
A download is a file transfer from the machine on which the participant is browsing to the server that hosts Oracle BPM WorkSpace. In this example, c:/tmp/clientFile is on the machine on which the participant is browsing.
myClientFileD = ClientFile(sourcePath : "C:/tmp/clientFile")
binaryB = downloadBinaryFrom(myClientFileD,
message :"Binary File: " + myClientFileD.name)
In this example, a file is transferred to the WorkSpace server:
FilePName = downloadFileFrom(myClientFileD, destination : "/tmp/loadFile",
message : "Upload file from Browser machine to /tmp/loadFile")
FilePNameT = downloadToTemporaryFileFrom(myClientFileD,
message : "Temporary Upload to Server")
An upload is a file transfer from a specified URL to the machine on which the participant is browsing. In this example, C:/tmp/urlFile is created on the machine on which the participant is browsing:
myClURLFile = ClientFile(sourcePath : "C:/tmp/urlFile")
url = "http://repository/documents/documentToDownload"
clientFileNameU = uploadTo(myClURLFile, fromUrl : url,
message : "From URL")
clientFileNameU1 = uploadToTemporary(myClURLFile, fromUrl : url,
extension : "url",
message : "From URL, extension url")
This example provides many code examples of managing files.
This code creates a file:
testfile = ClientFile("/tmp/testfile.txt")
fileok = createNewFile(testfile, silent : true)
This code deletes testfile.txt:
delete testfile
using sourcePath = "/tmp/testfile.txt",
silent = true
This code returns true if the file is a directory:
display ("Is this file a Directory: " + testfile.directory)
This code returns true if a file exists:
display ("File exists: " + exists(testfile))
This code returns the file's entire path name, which is /tmp/testfile.txt.
display ("File's fullname: " + testfile.fullName)
This code returns true if the file is hidden:
display ("File is hidden?: " + testfile.hidden)
This code returns the date and time when the file was most recently modified. Note that Time.valueOf() requires a value in microseconds.
display ("Last file modification: " + Time.valueOf(lastModified(testfile)* 1000))
This code returns the length of the file:
display ("File's length: " + length(testfile))
This code returns the file name. In this example, the file name is testfile.txt.
display ("File's name: " + testfile.name)
This code returns the file's path. In this example, the file path is /tmp.
display ("File's path: " + testfile.path)
This code returns true if the file is read-only:
display ("File is readonly?: " + testfile.readOnly)
This code returns the directory separator character. In Windows, the directory separator is \ . In Unix, the directory separator is /.
display ("Directory separator: " + testfile.separator())
This code returns all files that are in the /tmp directory:
result2 = testfile.listFileNames(sourcePathFile : "/tmp", silent : false)
for each f1 in result2
do
display f1
end
This code copies testfile to copytestfile:
copy testfile
using sourcePath = "/tmp/testfile.txt",
destinationPath = "/tmp/copytestfile.txt",
silent = false
display ("Check that file was copied to copytestfile")
This code deletes copytestfile:
delete testfile
using sourcePath = "/tmp/copytestfile.txt",
silent = false
display ("Check that copytestfile was deleted")
This code renames testfile to testfileRen.txt:
rename testfile
using sourcePath = "/tmp/testfile.txt",
destinationName = "/tmp/testfileRen.txt",
silent = true
display ("Check that testfile was renamed to testfileRen.txt")
This code moves /tmp/testfileRen.txt to /Temp/testfileRen.txt:
move testfile
using sourcePath = "/tmp/testfileRen.txt",
destinationPath = "/Temp/testfileRen.txt",
silent = false
display ("Check that /tmp/testfileRen was moved to /Temp")
delete testfile
using sourcePath = "/Temp/testfileRen.txt",
silent = false
display ("Check that /Temp/testfileRen was deleted")