Skip to main content
Archived

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

Related products:FME Form
siennaatsafe
fmelizard
  • siennaatsafe
    siennaatsafe
  • fmelizard
    fmelizard

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

<strong>This post is closed to further activity.</strong><br /> It may be a question with a best answer, an implemented idea, or just a post needing no comment.<br /> If you have a follow-up or related question, please <a href="https://community.safe.com/topic/new">post a new question or idea</a>.<br /> If there is a genuine update to be made, please contact us and request that the post is reopened.

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings