Last active
July 21, 2017 07:51
-
-
Save JLiu1272/c2f71213990a341b6fb77c0208e16727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CURL COMMANDS | |
Auth_Token: AUTH_tked6a45449d034facb8d46572847c0076 | |
4 Things To Pay Attention To: | |
- Building an API that allows you to Add multiple objects into a container | |
- Creating an API for a set of Metadata | |
- Cannot upload files that are greater than 5GB, Build an API that will do automatic segmentation | |
- No longer using AWS, so we should build an API that allows objects to be added to both Clouds (Swift & Azure) | |
#Authentication | |
curl -v -H X-Storage-User:companyA:AdminA -H X-Storage-Pass:password -k http://hln2329p:8080/auth/v1.0 | |
#GET Command | |
--- Lists out all the containers inside CompanyA --- | |
curl -v -X GET -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA | |
--- Adding Limitations --- | |
curl -v -X GET -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA/folder1?limit=2 | |
--- Paging through containers with a marker --- | |
-Important to use \&, if you do &, it will run something in its own thread | |
curl -v -X GET -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA?marker=folder1\&limit=2 | |
#PUT Command | |
curl -v -X PUT -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA/folder1/585KB.PNG -T /home/testuser/585KB.PNG | |
#BROWSE Command | |
--- Show Object's MetaData --- | |
- Gives you information about Number of Containers in the account (X-Bytes-Used) | |
curl -v -X HEAD -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA | |
#DELETE Command | |
curl -v -X DELETE -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA/folder1/585KB.PNG | |
#POST Command - Add Metadata | |
----- Caution ------ | |
- Must post all metadata all at once | |
- If you make update again, it simply replaces existing metadata | |
- Format of Metadata is as follows: X-{Object/Container/Account}-{Name}:{Value} | |
curl -v -X POST -H X-Object-Meta-Brand:BMW -H X-Object-Meta-Model:x3 -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA/folder1/mazda-cx4.png | |
#Formatting (JSON or XML) | |
curl -X GET -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -k http://hln2329p:8080/v1/AUTH_companyA/folder1?format={format choice} | |
#Changing ACL | |
More Info: https://docs.openstack.org/developer/swift/misc.html | |
---- This would give public access: meaning that when you type the link to browser, all objects within container will be visible to the world --- | |
curl -v -X PUT -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -H "X-Container-Read: .r:*,.rlistings" -k http://hln2329p:8080/v1/AUTH_companyA/read_folder | |
#Copying Files | |
curl -v -X PUT -H "X-Copy-From: /test_folder/test1.txt" -H Content-Length:0 -H X-Auth-Token:{Token} -k http://hln2329p:8080/v1/AUTH_companyA/test_folder/test2.txt | |
#GSWAuth | |
----- Add User with Admin Prvilleges -------- | |
gswauth-add-user -K password1 -a companyA AdminF password | |
----- List Users ------------------- | |
gswauth-list -K password1 companyA | |
------------------ MetaData ---------------------------------- | |
1) Metadata for housekeeping: (i.e Expiration Date) | |
curl -v -X PUT -H X-Auth-Token:AUTH_tked6a45449d034facb8d46572847c0076 -H X-Delete-After:100 -k http://hln2329p:8080/v1/AUTH_companyA/folder1/585KB.PNG -T /home/testuser/585KB.PNG | |
2) Meta Data For Search Filters (i.e Office Code ) | |
SWIFT CLI Commands | |
--- List Containers inside Account --- (GET) | |
swift -A http://hln2329p:8080/auth/v1.0 -U companyA:AdminA -K password list | |
--- Upload Files into Container --- (PUT) | |
swift -A http://hln2329p:8080/auth/v1.0 -U companyA:AdminA -K password folder1 thumbs_up.png | |
--- Delete Files in Container --- (DELETE) | |
swift -A http://hln2329p:8080/auth/v1.0 -U companyA:AdminA -K password delete folder1 thumbs_up.png | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment