Last active
December 28, 2015 02:39
-
-
Save Micka33/7429524 to your computer and use it in GitHub Desktop.
how to go through RIAKCS&RIAK to manage files
This file contains hidden or 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
# Create a user in RIAK & RIAKCS | |
# Get the user | |
Me = User.find_by_index(:email, "[email protected]") | |
Me = User.find '52820a5994da266b19000002' | |
# Or create a new one | |
Me = User.new username:'Micka2', email:'[email protected]', firstname:'micka2', lastname:'cassy2', password:'testtest2', password_confirmation:'testtest2' | |
Me.save | |
# In RIAKCS, Use FOG | |
# Instanciate the Fog API to go through RIAKCS | |
s3 = Fog::Storage.new RiakCS::BucketManager.get_credentials(Me.key_id, Me.key_secret) | |
# List all directories | |
s3.directories | |
# Count files in first directory | |
s3.directories[0].files.count | |
# Delete a file | |
s3.directories[0].files[0].destroy | |
# In RIAK, use the model | |
# Delete a file in RIAK | |
Resource.get_root_by_user(Me.key)[0].destroy | |
# URL TO UPLOAD | |
curl -s -v -T [pathtofile] -H 'x-amz-acl:public-read' -H 'Content-Type: [Content/Type]' -X PUT [url] | |
eg: | |
curl -s -v -T ./test.jpeg -H 'x-amz-acl:public-read' -H 'Content-Type: image/jpeg' -X PUT http://52820a5994da266b19000002.data.riak.dev/6c4e8d0a-4b8c-11e3-a672-10ddb1b55777?AWSAccessKeyId=KCLM2T6CHH8UCVMSDU-X&Expires=1384291223&Signature=yuGmh2qTwa4VPVjvTyVvfwP0jMc%3D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DOC: http://fog.io/storage/