Creating a file with contents using a single POST requires that it be submitted using a multi-part/form post data.
If you first create the file by submitting the application/vnd.csp.file-info+xml entity data to the ContainerContents resource you may then do a PUT of the binary data of the file without using a multi-part/form to the URI returned which will be the newly created resource's uri.
You can duplicate this using the command line curl by doing the following sequence:
- curl -u <username>:<password>
https://cloud.example.com/v2/containers/<oid>/contents -X POST -H "Content-Type: application/vnd.csp.file-info+xml" -d "<file><name>New File.txt</name><mime_type>application/txt</mime_type><public>false</public></file>"
This will return a new resource uri of the form:
https://cloud.example.com/v2/files/<oid>
Replace the content of the file by putting your file data to the 'content' uri of the file resource returned.
curl -u <username>:<password>
https://cloud.example.com/v2/files/<oid>/content -X PUT -d @testfile.txt -v
You should receive a "204 No Content" as the response.
Which language are you using to drive libcurl?
A self contained example would be helpful in solving this issue.