Example: Sending a file using an HTTP request

You can send a single file to a destination agent file system by submitting a request through the IBM® MQ Managed File Transfer Web Gateway.

About this task

File contents can be uploaded to any standard IBM MQ Managed File Transfer agent as POST data using the multipart/form-data Content-Type. This should be submitted to a location containing the target agent and file destination in the following format: /fte/file/agent/agent_name@queue_manager/filepath. You can modify the file transfer request parameters using the custom HTTP headers described in HTTP headers and HTML form fields for using the Web Gateway.

When you submit a file transfer request using the Web Gateway, your user ID in the application server environment is checked to see if it is mapped to a WebSphere® MQ Message Descriptor (MQMD) user ID. The mappings between application server user ID (web user ID) and MQMD user ID are created by your Web Gateway administrator. For more details, see the topic Example: Mapping web user IDs to MQMD user IDs. If there is no MQMD user ID defined for your web user ID, the value of the defaultMQMDUserID servlet initialization parameter is used. This parameter is defined during deployment of the Web Gateway application.

Use the following example to transfer a text file to the destination file path destination-root-path/temp and destination file name myfile.txt on the destination agent ACCOUNTS. Use an MD5 checksum to check the integrity of the transferred file. The content of the file is:


Account No, Balance
123456, 100.00
234567, 1022.00
345678, 2801.00
456789, 16.75
The server hosting the IBM MQ Managed File Transfer Web Gateway is example.com.

Procedure

  1. Create an HTTP request with this format:
    
    POST HTTP/1.1 /fte/file/agent/ACCOUNTS@QM/temp
    Host: example.com
    Content-Type: multi-part/form-data; boundary=Aa6b74
    x-fte-checksum: MD5
    
    
    --Aa6b74
    Content-Disposition: form-data; name="files"; filename="myfile.txt"
    Content-Type: text/plain
    
    Account No, Balance
    123456, 100.00
    234567, 1022.00
    345678, 2801.00
    456789, 16.75
    --Aa6b74
    
  2. Submit the request to the Web Gateway. The Web Gateway returns an HTTP response with this format.
    
    HTTP/1.1 200 OK
    Server: WAS/6.0
    Content-Length: 0
    x-fte-id: 4d63c28ae6e72eb9c51cd812736acd4362ef5
    
    <transfers> 	
    	<submission id="4d63c28ae6e72eb9c51cd812736acd4362ef5"> 	
    	</submission> 
    </transfers>
    
    The value of x-fte-id is the transfer ID. You can use this transfer ID in an HTTP request for information about the status of the transfer. For an example request, see the topic Example: Viewing the status of a file transfer using an HTTP request.