The uploadFile method

Saves a file to the repository from the local file system, with the option of creating a new version of the file if it already exists.

uploadFile(source,target,versionFlag)
Table 1. Input parameters for uploadFile
Field Use Type Description Example Value
source Required String The fully qualified path (on the local file system) of the file to upload "C:\Temp\Temp.txt"
target Required String The fully qualified path of the destination folder in the repository where the file is to be uploaded "/Temp Folder"
versionFlag Optional Boolean If the specified file already exists, a new version of the file is created True or False
Table 2. Return value for uploadFile
Type Description
String URI of the uploaded file
Table 3. Exceptions for uploadFile
Type Description
ResourceNotFoundException The source file or target folder does not exist.
ResourceAlreadyExistsException A file or folder with the same name as the source file exists in the target folder and the versionFlag parameter is not specified.
InsufficientParameterException Required parameters are not specified.

Example

This example uploads the file MyReport.rptdesign to the /Demo/Drafts folder in the repository. If the file already exists, a new version of the file is uploaded using the versionFlag parameter.


from pes.util.PESExceptions import *
from pes.api.PESImpl import PESImpl
pesImpl = PESImpl("admin", "spss", "localhost", "8080")
try:
   uri = pesImpl.uploadFile(source="C:\Demo\MyReport.rptdesign",target="/Demo/Drafts")
   print "URI for the uploaded file is: ", uri
except ResourceAlreadyExistsException:
   uri = pesImpl.uploadFile(source="C:\Demo\MyReport.rptdesign",target="/Demo/Drafts",
      versionFlag=True)
   print "URI for the uploaded file is: ", uri