The example that follows uses these files:
$ ls -l
-rw-r--r-- 1 gordy gordy 108 2010-06-30 15:48 file.xml
-rw-r--r-- 1 gordy gordy 17 2010-06-30 15:39 part1.dat
-rw-r--r-- 1 gordy gordy 17 2010-06-30 15:39 part2.dat
file.xml:
<file>
<name>sample.txt</name>
<mime_type>text/plain</mime_type>
<public>false</public>
</file>
part1.dat:
This is part 1.
part2.dat:
This is part 2.
First I'll create a file by posting it to my root container's contents URI.
$ curl -i -u ACCOUNT:PASSWORD \
-X POST \
-H 'X-Client-Specification: 2' \
-H 'Content-Type: application/vnd.csp.file-info+xml' \
https://pcsbeta.mezeo.net/v2/containers/682FC496-40C8-11DF-8C48-BF2FA59144D5/contents \
-d@file.xml
HTTP/1.1 201 Created
Date: Wed, 30 Jun 2010 20:48:57 GMT
Server: Apache/2.2.3 (Red Hat)
Location: https://pcsbeta.mezeo.net/v2/files/E77E5D80-8488-11DF-A5E9-0030485F2412
Transfer-Encoding: chunked
Content-Type: text/uri-list
https://pcsbeta.mezeo.net/v2/files/E77E5D80-8488-11DF-A5E9-0030485F2412
Notice the URI of the new file that was created? Now I will upload my first
part by PUTting it to the content URI of the file I just created. I know that
I am uploading a total of 34 bytes and am going to write the first 17 bytes.
$ curl -i -u ACCOUNT:PASSWORD \
-X PUT \
-H 'Content-Range: bytes 0-16/34' \
https://pcsbeta.mezeo.net/v2/files/E77E5D80-8488-11DF-A5E9-0030485F2412/content \
--data-binary @part1.dat
Now I will upload the second part. I know that I am uploading the last 17
bytes of the file.
$ curl -i -u ACCOUNT:PASSWORD \
-X PUT \
-H 'Content-Range: bytes 17-34/34' \
https://pcsbeta.mezeo.net/v2/files/E77E5D80-8488-11DF-A5E9-0030485F2412/content \
--data-binary @part2.dat
Now let's download the file and check our work:
$ curl -i -u ACCOUNT:PASSWORD \
https://pcsbeta.mezeo.net/v2/files/E77E5D80-8488-11DF-A5E9-0030485F2412/content
HTTP/1.1 200 OK
Date: Wed, 30 Jun 2010 21:12:14 GMT
Server: Apache/2.2.3 (Red Hat)
Cache-Control: no-cache
Content-Disposition: attachment; filename=sample.txt
Transfer-Encoding: chunked
Content-Type: text/plain; charset=UTF-8
This is part 1.
This is part 2.