Example: Deleting a file from a file space

You can delete a file from your file space by submitting an HTTP request to the WebSphere® MQ Managed File Transfer Web Gateway. If you set the header x-fte-include-file-in-response to true, the contents of the file are returned in the HTTP response from the Web Gateway.

About this task

A successful deletion request returns an HTTP status code of 200 and, if specified in the request, the contents of the deleted file. The request will fail if the user submitting the request is not the owner of the file space.
Note: The security role wmqfte-admin can delete a file from a file space, but cannot receive the contents of the deleted file. If a user with the security role wmqfte-admin attempts to delete a file and request the file contents, the request fails with a resource error. For more information, see User roles for the Web Gateway.

The following steps describe how to submit a request. In this example, the server hosting the WebSphere MQ Managed File Transfer Web Gateway is example.com. The name of the file space is jack, it contains a file report.txt, and the user requesting the file deletion is the owner of the file space. The transfer ID 414d5120514d5f67617265746862202067732c4c20c25a03 is the hexadecimal ID of the transfer that put the file in the file space, and this ID is returned when you list the contents of a file space. For more information about the format of file space query responses, see File space query response formats.

The header x-fte-include-file-in-response:true specifies that the contents of report.txt is returned in the body of the response. If you do not specify the value of this header, it defaults to false and the file is deleted but its contents are not returned.

Procedure

  1. Create an HTTP request with the following format:
    DELETE HTTP/1.1 /filespace/jack/414d5120514d5f67617265746862202067732c4c20c25a03/report.txt
    Host: example.com
    User-Agent: mozilla
    x-fte-include-file-in-response:true
    
  2. Submit the request to the Web Gateway. The Web Gateway returns an HTTP response with the following format:
    HTTP/1.1 200 OK
    Server: WAS/6.0
    Content-Length: 1762
    Content-MD5: 9608f0d8cdcb804d185ab3cb959dba6f
    Content-type: text/plain; charset=Cp1252
    Content-Disposition: attachment; filename="report.txt"
    
    Account No, Balance
    123456, 100.00
    234567, 1022.00
    345678, 2801.00
    456789, 16.75