How to stream a file over HTTP or HTTPS in BusinessWorks and BusinessWorks Container Edition

Emmanuel Marchiset
3 min readJan 28, 2024

One challenge while handling files in BusinessWorks is that we generally don’t have control on the actual file sizes and this sometimes require to use large amounts of memory and may even create situations where ‘Out of Memory’ errors occurs.

An interesting feature introduced in BusinessWorks 6.9.1 is the capability to send or receive a file using HTTP Send and HTTP Receive activities without having to load the whole file content in memory. With this new feature files are sent or received in chunks of a limited size and directly read from disk or wrote to disk. Such approach is sometimes referred to has file streaming.

This blog article is to explain how to use this new feature.

Sending a file over HTTP

The ‘Send HTTP Request’ activity has to be configured with the following:

. In the General tab, select an available HTTP Client resource, or createn a new one, and set the Post Data Type configuration option to ‘File’

Send HTTP Request activity configured to send a file without loading its content in memory

. In the Input tab
— Set the ‘Method’ field to “POST”
— Set the ‘FilePath’ field to the full path of the file to be sent
— Set the ‘Time out’ field to an Integer value (in milli seconds — for example 60 000 for a minute)
— Set the ‘Dynamic Headers’ -> ‘Header’ -> ‘Name’ to “Content-Disposition”
— Set the ‘Dynamic Headers’ -> ‘Header’ -> ‘Value’ to “attachment; filename=<file name at reception>” (for example ClientFile.txt)

Input of the Send HTTP Request activity to send a file

Receiving a file over HTTP

The ‘Receive HTTP’ activity has to be configured with the following:

. In the General tab, select an available HTTP Connection resource, or create a new one, and set the Output Style configuration option to ‘File’

Receive HTTP activity configured to receive a file

. In the Advanced tab :
— Check the ‘Write to File’ option
— Set the Buffer Size to an integer value (in bytes — the default value is 1024)
— Set the Directory to the name of the directory where received files are written
— Optionally you can set the ‘Threshold Data’ option to a value (in bytes), when the value is zero files are always written to the defined target directory, when the value is greater than zero received files are written to disk only if they are greater than this value

Receive HTTP activity configured to receive a file without loading its content in memory

. Don’t forget to include a ‘Send HTTP Response’ activity after the ‘Receive HTTP’ activity

Example of a process receiving files

--

--

Emmanuel Marchiset

I work as an Architect at TIBCO Software on Integration products. Opinions here are my own.