You are viewing an older version of this section. Click here to navigate to the latest version.

Create or Update a File

The /mmc/api/servers/<myServerId>/files/<myFile.xml> resource, when called with the HTTP POST operation, creates or updates a file on the server. If the file does not exist, then the resource creates a new file. If the file already exists, then the resource updates the file with the new data. The file location is relative to the directory in which Mule is installed.

If you want to be sure that you are updating an existing file, and not creating a new file, then use this resource with the PUT command instead. When invoked with the PUT command, the resource only updates an existing file and does not create a new file.

Specify the server URL and file path using the form http://localhost:8080/mmc/api/servers/73d89173-290e-4cb3-a61c-e11deb74767d/files/<path>; where <path> is the path to the file you want to create or update and 73d89173-290e-4cb3-a61c-e11deb74767d is the server id. The request body contains the new data for the file.

Example Request

The following example shows how to invoke this resource with the POST command to either update or create the myconfig.xml file.

(curl example)curl --basic -u admin:admin -v --header "Content-Type: application/octet-stream" --data-binary "@localMyconfig.xml" http://localhost:8080/mmc/api/servers/'local$d6f9cf62-f09c-4bf6-9d73-a16fec39dffc'/files/logs/myconfig.xmlPOST http://localhost:8080/mmc/api/servers/local$d6f9cf62-f09c-4bf6-9d73-a16fec39dffc/files/myconfig.xmlContent-Type: application/octet-stream ...file data...

Example Response

A successful request returns the following response:

200 OKContent-Length: 0Content-Type: application/jsonServer: Apache-Coyote/1.1Date: Tue, 10 Nov 2009 16:17:12 GMT