Jump to content
  • BW6.X - BWCE - How to stream a file over HTTP or HTTPS in BusinessWorks and BusinessWorks Container Edition


    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’

    1*3dWv7vxnIYots5_FxRN3nQ.png

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

    1*bvzpL6g5fYct1CqweYmiHg.png

    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’

    1*OXOHb6ev5XquW8dNqXXmBg.png

    . 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

    1*WfNdwxUMQYsU-jq4k40i7g.png

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

    1*W1Mbp6Bew-3CQ-pUFiNq7A.png

    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...