Example: Creating a file space

Before a file can be transferred to a user file space, you must create a file space for that user. You can create a file space by using the WebSphere® MQ Managed File Transfer Web Gateway.

About this task

Use the Web Gateway administration API to request the creation of a user file space. For more information about the format of a file space creation request, see File space create or alter request format. A successful request returns an HTTP status code of 200.

You must have either the wmqfte-filespace-create role or the wmqfte-admin role associated with your user account to create a file space. For more information about security roles for the Web Gateway, see User roles for the Web Gateway and Attempting to create a file space without the required authority.

If you have the security role wmqfte-admin, you can also create a file space by using the administrative console. For more information, see Web Gateway administrative console.

The following steps describe how to submit a POST request to create a file space. In this example, the server hosting the Web Gateway is example.com and the HTTP request is submitted using a web browser that identifies itself as mozilla. The name of the file space and the name of the user who owns the file space is andrew and the file space can take up a maximum of 1,048,576 bytes on the file system. The user bill and any user whose user name matches the regular expression pattern fte.* are authorized to send files to the file space. The user clive is not authorized to access the user file space. You can use Java regular expressions to pattern-match either or both sets of the users in the authorized and unauthorized XML sections. For more information, see Regular expressions used by WebSphere MQ Managed File Transfer.

In the following example, one of the agent-user entries in the authorized section uses the regular expression fte.*. This regular expression matches any user names starting with fte. In the situation that you wanted to authorize all user names starting with fte apart from fteuser, you could add an additional agent-user entry with a value of fteuser in the unauthorized section. This element would take precedence over the fte.* regular expression, because unauthorized entries overrule authorized entries when they evaluate to the same value.

In the following example, one of the agent-user entries in the authorized section is the user name accounts1. One of the agent-user entries in the unauthorized section is the regular expression accounts*, this overrides the authorization given to the user name accounts1. All users that match the regular expression accounts*, including the user accounts1, are not authorized on this file space.

Procedure

  1. Create an HTTP request with the following format:
    POST HTTP/1.1 /admin/filespace/andrew
    Host: example.com
    User-Agent: mozilla
    Content-Type: application/xml
    Content-Length: 266
    
    <?xml version="1.0" encoding="UTF-8"?>
    <filespaces>
      <filespace>
        <quota bytes="1048576"/>
        <writers>
          <authorized>
            <agent-user>bill</agent-user>
            <agent-user>accounts1</agent-user>
            <agent-user>fte.*</agent-user>
          </authorized>
          <unauthorized>
            <agent-user>fteuser</agent-user>
            <agent-user>accounts*</agent-user>
          </unauthorized>
        </writers>
      </filespace>
    </filespaces>
  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/7.0
    Content-Length: 0

    A file space called andrew now exists and files can be transferred to it. The users andrew, bill, and any user whose name begins with fte, except for the user fteuser, can transfer files to the file space. No users that match the regular expression accounts* can transfer files to the file space.

    For information about how to transfer files to a file space, see Example: Transferring a file to a file space.

    The request to create a file space is logged to the application server event log. For more information, see File space administration logging format.

    An invalid request returns an HTTP error code and a WebSphere MQ Managed File Transfer error message. To identify the cause of the error, see Troubleshooting the Web Gateway.