Example application¶
Initialization¶
Install requirements:
$ pip install -e .[all]
$ cd examples
$ ./app-setup.py
$ ./app-fixtures.sh
Run example development server:
$ FLASK_APP=app.py flask run --debugger -p 5000
Run example worker:
$ celery worker -A app.celery -l info --purge
Note
You must have a Redis running on localhost.
Endpoints¶
Administration interface is available on:
http://localhost:5000/admin/
REST API is available on:
http://localhost:5000/files/
REST API¶
Below are some example queries you can make to the REST API. Most queries will be operating on a bucket, so let’s first define a env variable:
$ B=11111111-1111-1111-1111-111111111111
Bucket operations¶
Create a bucket:
$ curl -X POST http://localhost:5000/files
List objects:
$ curl http://localhost:5000/files/$B
List object versions:
$ curl http://localhost:5000/files/$B?versions
List multipart uploads:
$ curl http://localhost:5000/files/$B?uploads
Check bucket existence:
$ curl -i -X HEAD http://localhost:5000/files/$B
Object operations¶
Download a file:
$ curl -i http://localhost:5000/files/$B/AUTHORS.rst
Upload a file:
$ curl -i -X PUT --data-binary @../INSTALL.rst \
http://localhost:5000/files/$B/INSTALL.rst
Delete a file (creates a delete marker):
$ curl -i -X DELETE http://localhost:5000/files/$B/INSTALL.rst
Remove a specific version (removes file from disk):
$ curl -i -X DELETE http://localhost:5000/files/$B/INSTALL.rst?versionId=...
Multipart file upload¶
Create a multipart upload:
$ curl -i -X POST \
"http://localhost:5000/files/$B/LICENSE?uploads&size=8&partSize=4"
List parts of a multipart upload:
$ curl http://localhost:5000/files/$B/LICENSE?uploadId=...
Upload parts:
$ echo -n "aaaa" | curl -i -X PUT --data-binary @- \
"http://localhost:5000/files/$B/LICENSE?uploadId=...&partNumber=0"
$ echo -n "bbbb" | curl -i -X PUT --data-binary @- \
"http://localhost:5000/files/$B/LICENSE?uploadId=...&partNumber=1"
Complete a multipart upload (Celery must be running):
$ curl -i -X POST http://localhost:5000/files/$B/LICENSE?uploadId=...
Abort a multipart upload (Celery must be running):
$ curl -i -X DELETE http://localhost:5000/files/$B/LICENSE?uploadId=...