Personal tools

Swap:Command Line Access

From Adapt

Jump to: navigation, search

Uploading Data

SWAP uses http PUT to allow new data to be uploaded. Clients that are uploading data need to be able to follow http redirects (301 and 302).

curl can be used to place data into SWAP.

To bulk upload a directory, you can use find in conjunction with curl to send lots of files.

Example: upload a single file (Screenshot.png)

curl -L -T Screenshot.png http://naraapp13:8080/put/web/test/uploadtest/back5/Screenshot.png

Example: upload backgrounds to web/test/uploadtest/back5

find backgrounds -type f -exec curl -L -T {} http://naraapp13:8080/put/web/test/uploadtest/back5/{} \;

What happens under the hood.

A client only needs to talk to one of the SWAP servers to upload its data. If it attempts to place a file on a server that doesn't belong, that server will issue a redirect and tell the client the correct server to talk to.

Example: details of the redirect. app13 isn't responsible for the file Screenshot2.jpg, so it issues a redirect to app14 which accepts the file.

[toaster@loach ~]$ curl -vL -T Screenshot.png http://naraapp13:8080/put/web/test/uploadtest/back5/Screenshot2.png
* About to connect() to naraapp13 port 8080
*   Trying 128.8.132.177... connected
* Connected to naraapp13 (128.8.132.177) port 8080
> PUT /put/web/test/uploadtest/back5/Screenshot2.png HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: naraapp13:8080
> Accept: */*
> Content-Length: 163164
> Expect: 100-continue
> 
< HTTP/1.1 301 Wrong node
< Location: http://naraapp14.umiacs.umd.edu:8080/put/web/test/uploadtest/back5/Screenshot2.png
< Content-Length: 0
< Date: Thu, 04 Feb 2010 04:26:18 GMT
* Connection #0 to host naraapp13 left intact
* Issue another request to this URL: 'http://naraapp14.umiacs.umd.edu:8080/put/web/test/uploadtest/back5/Screenshot2.png'
* About to connect() to naraapp14.umiacs.umd.edu port 8080
*   Trying 128.8.132.178... connected
* Connected to naraapp14.umiacs.umd.edu (128.8.132.178) port 8080
> PUT /put/web/test/uploadtest/back5/Screenshot2.png HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: naraapp14.umiacs.umd.edu:8080
> Accept: */*
> Content-Length: 163164
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
HTTP/1.1 201 wrote new file uploadtest/back5/Screenshot2.png
< Content-Type: application/octet-stream
< Content-Length: 0
< Date: Thu, 04 Feb 2010 04:26:18 GMT
* Connection #1 to host naraapp14.umiacs.umd.edu left intact
* Closing connection #0
* Closing connection #1