Skip to main content
Archived

Automation of python script zipping files using FME Server allowing user paramet

Related products:FME Form
  • April 18, 2017
  • 0 replies
  • 20 views

***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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.