Binary File Transfers with UHTTP

The Uniface UHTTP component provides enables you to transfer files for upload or download.

The LOAD_FILE_CONTENTS operation inserts a file into the message body for upload. The DUMP_FILE_CONTENTS operation handles the body of a response message as a file download.

These file operations do not support multi-part HTTP requests, so you can't use them for a request body the contains, for example, both a simple text message and a file attachment.

Note:  It is possible to construct this type of request with textual data, and to represent binary data as textual data with base64 or hex encodings. However, you need to construct such content and provide appropriate headers yourself.

Many APIs impose an upper limit to the size of file that can be transfered in one request. As the file size increases, the chances of errors occuring also increase. Rather than having to re-send a file from the start, most APIs offer a restartable transfer that involves sending pieces, or chunks, of the file. This is often called chunked transfer. The Uniface supports both the simple all-in-one and chunked file transfers.

Note:  Chunked file transfer should not be confused with the HTTP Transfer-Encoding: chunked, which is a different form of segmentation.

Uniface has a theoretical limit of 2G for either a simple file or chunked file transfer. Bear in mind that for file transfers, the complete file contents or the chunk size are read into a single buffer in memory.

One file should be completely handled before starting on the next one within a single instance of the UHTTP component.

You can use ProcScript command to define the required headers and any required file handing. If you need to send compressed file data, you can use ProcScript file handling commands to place a file into a zip file and then specify the zip file to the operations.

There is no default header handling or character set encoding in the SEND when the file operations are used to provide the contents

Related Topics