Skip to main content
Solved

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


tb09114
Supporter
Forum|alt.badge.img+23

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.

View original
Did this help you find an answer to your question?

5 replies

takashi
Influencer
  • 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+23
  • 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
Influencer
  • 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+1
  • 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!!!


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