Skip to content

Instantly share code, notes, and snippets.

@Micka33
Last active December 28, 2015 02:39
Show Gist options
  • Save Micka33/7429524 to your computer and use it in GitHub Desktop.
Save Micka33/7429524 to your computer and use it in GitHub Desktop.
how to go through RIAKCS&RIAK to manage files
# Create a user in RIAK & RIAKCS
# Get the user
Me = User.find_by_index(:email, "mickael3@beingenious.com")
Me = User.find '52820a5994da266b19000002'
# Or create a new one
Me = User.new username:'Micka2', email:'mickael2@beingenious.com', 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
@Micka33
Copy link
Author

Micka33 commented Dec 13, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment