***Note from Migration:***
Original Title was: Automation of python script zipping files using FME Server allowing user parameters
Just an alternative to using zipArchiver transformer and Data Download Service
===========================================================================
import os
import zipfile
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
if __name__ == '__main__':
zipf = zipfile.ZipFile ('$(FME_SHAREDRESOURCE_DATA)Upload/$(nameUploadedFiles)', 'w', zipfile.ZIP_DEFLATED)
zipdir ('$(FME_SHAREDRESOURCE_DATA)Upload/', zipf)
zipf.close()
===========================================================================
Initially I was to use zipArchiver transformer in my workbench, but our IT Security did not allow me to download and use it. So I chose to create user parameter(nameUploadedFiles) and add the lines of simply Python code for Job Submitter service to be published. So, Data Download Service is not required to be published at all. Users can login into FME Server, upload files in the folder, specify the name and run the workspace to get the zipped file.