Question

Datadownload - change filename on ZIP

  • 5 January 2018
  • 5 replies
  • 33 views

Badge +21

I have looked at this:

https://knowledge.safe.com/articles/678/create-a-custom-download-link-for-results-from-dat.html

I want to be able to set the exact-filename of the zip-file within FME Workbench for the download service. Si instead of the URL like this:

http://fmeserver/fmedatadownload/FME_2D764B0C_1515155526785_73956.zip

I want to be able to define a parameter in a workspace called:

ZIPFILENAME = myfilename.zip

So the Datadownloadservice serves the file:

http://fmeserver/fmedatadownload/myfilename.zip

In other workspaces I will have completely different zip-filenames.

Any way to do this? I manage to create all the data within the correct file and use the filecopy to copy the file to the correct place (within fmedatadownload/) but I can not persuade the fME Datadownloadservice to use that zipfile and not create a random-zipfile.


5 replies

Badge +21

FYI: Using: $(FME_SERVER_DEST_DIR) gives the complete outputfolderandfilename

http://fmeserver/fmedatadownload/FME_2D764B0C_1515155526785_73956.zip

Userlevel 2
Badge +17

Hi @sigtill, although it may not be ideal, but this hack might work as expected.

1. Create a scripted parameter that returns a server resource file path which can be accessed with this download service URL: https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

import os
path = FME_MacroValues.get('FME_SERVER_DEST_DIR', None)
if path:
    dir, _ = os.path.split(path)
    dir = os.path.join(dir, FME_MacroValues['FME_JOB_ID'])
else:
    dir = '.' # For test with FME Desktop.
return '%s/myfilename.zip' % dir
2. Link the destination dataset parameter of the writer to the scripted parameter.

3. Add an additional dummy writer to the workspace.

4. Publish the workspace with Data Download Service including only the dummy writer to download.The result from the dummy writer will be archived in the default zip file, but the "myfilename.zip" can be saved separately, and you can download it from this URL.

https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

Badge +21

Hi @sigtill, although it may not be ideal, but this hack might work as expected.

1. Create a scripted parameter that returns a server resource file path which can be accessed with this download service URL: https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

import os
path = FME_MacroValues.get('FME_SERVER_DEST_DIR', None)
if path:
    dir, _ = os.path.split(path)
    dir = os.path.join(dir, FME_MacroValues['FME_JOB_ID'])
else:
    dir = '.' # For test with FME Desktop.
return '%s/myfilename.zip' % dir
2. Link the destination dataset parameter of the writer to the scripted parameter.

3. Add an additional dummy writer to the workspace.

4. Publish the workspace with Data Download Service including only the dummy writer to download.The result from the dummy writer will be archived in the default zip file, but the "myfilename.zip" can be saved separately, and you can download it from this URL.

https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

Well, the download-link in the email that is sent will still be 

 

http://fmeserver/fmedatadownload/FME_2D764B0C_1515155526785_73956.zip

 

 

I know I can copy the files as wanted using File and Directory writer into that zipfile, and then use the FMEServerEmailgenerator and FMEServerNotifier to send the e-mail. However I wanted to use the built-in feature in FME Server without this "hack".

 

 

I have added this as an idea, please vote for it if it might be usefull for you in getting nicer naming on the zip-files: https://knowledge.safe.com/idea/61029/easily-override-zip-file-name-on-fmeserver-datadow.html?

 

 

 

Badge +22

Back in 2013 FME server couldn't handle zipping datasets larger than a certain size (either 2 or 4GB) we got around that limitation by using an custom nm directive and a modification to the FmeEngineConfig.txt. to create our own zip file that was 64-bit compatible.

Userlevel 2
Badge +17

Hi @sigtill, although it may not be ideal, but this hack might work as expected.

1. Create a scripted parameter that returns a server resource file path which can be accessed with this download service URL: https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

import os
path = FME_MacroValues.get('FME_SERVER_DEST_DIR', None)
if path:
    dir, _ = os.path.split(path)
    dir = os.path.join(dir, FME_MacroValues['FME_JOB_ID'])
else:
    dir = '.' # For test with FME Desktop.
return '%s/myfilename.zip' % dir
2. Link the destination dataset parameter of the writer to the scripted parameter.

3. Add an additional dummy writer to the workspace.

4. Publish the workspace with Data Download Service including only the dummy writer to download.The result from the dummy writer will be archived in the default zip file, but the "myfilename.zip" can be saved separately, and you can download it from this URL.

https://<FME Server domain>/fmedatadownload/<Job ID>/myfilename.zip

I know the hack is not ideal, but you can also define a client custom keyword in order to include the download URL with an email subscriber associated to a topic.

 

For example, if you add a user parameter called "nm_custom_zip" storing "myfilename.zip" to the workspace, you can construct the download URL that appears in the email body with this expression. Here, {custom_zip} is a client custom keyword that represents the value of "nm_custom_zip".

 

<fmeblock>{urlPrefix}/fmedatadownload/results/{id}/{custom_zip}</fmeblock>
Anyway, I voted up your Idea :-)

 

Reply