Skip to main content
Solved

Where to write file in PythonCaller and how to reference it for download?

  • May 28, 2025
  • 5 replies
  • 128 views

tb09114
Supporter
Forum|alt.badge.img+27

I am creating a PDF report in a PythonCaller and currently I am writing it into a subfolder of FME_SHAREDRESOURCE_TEMP.

I would like to know where I have to write the file to be able to generate a download link for it.
When I use normal writers than I reference the writer in the Download Service… but with a PythonCaller?

Best answer by takashi

Hi ​@tb09114 ,

A simple solution I can think of is, add a File Copy wirter to the workspace so that the file created by the Python script will be moved to a location, then publish the workspace to FME Flow as Data Download Service including the writer as a download writer.

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.

5 replies

takashi
Celebrity
  • Best Answer
  • May 28, 2025

Hi ​@tb09114 ,

A simple solution I can think of is, add a File Copy wirter to the workspace so that the file created by the Python script will be moved to a location, then publish the workspace to FME Flow as Data Download Service including the writer as a download writer.


david_r
Celebrity
  • May 28, 2025

I suspect that the simplest and most robust solution would be to write the PDF to a temporary folder in your PythonCaller (e.g. using the tempfile Python module or the TempPathnameCreator transformer), then read it back into the workspace with a FeatureReader using the DATAFILE binary format. Then send it to a regular writer, also of type DATAFILE, which you publish for the Download service. Be sure to set the mime-type accordingly, e.g. application/pdf.


tb09114
Supporter
Forum|alt.badge.img+27
  • Author
  • Supporter
  • May 28, 2025

@takashi What my PythonCaller returns is the path of the PDF report. The File Copy writer sounds like an easy solution but I have a hard time to set it up so it actually is using the path string to copy/move the file to another destination.


takashi
Celebrity
  • May 28, 2025

If the output feature from the PythonCaller has an attribute storing the file path of the PDF report, just rename it to “filecopy_source_dataset” then send the feature to the File Copy writer.


tmangan
Participant
Forum|alt.badge.img+3
  • Participant
  • May 29, 2025

@takashi your tip about the filecopy_source_dataset has ended months of frustration!!!!  Thank you!

I’ve been facing the same problem with an Excel I generate with Python due to a lot of advanced formatting, I’ve tried so many things but no joy until your tip!!!