Skip to content

Instantly share code, notes, and snippets.

@rodreegez
Created May 14, 2011 18:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodreegez/972474 to your computer and use it in GitHub Desktop.
Save rodreegez/972474 to your computer and use it in GitHub Desktop.
Retrive S3 files with Fog
require 'fog'
con = Fog::Storage.new(
provider: 'AWS',
aws_secret_access_key: 'ABC123',
region: 'eu-west-1',
aws_access_key_id: 'ABC123'
)
=> Fog::AWS::Storage object
my_dir = con.directories.get('my-dir')
=> Fog::AWS::Storage::Directory
my_dir.files
=> Fog::AWS::Storage::Files # xml representation of file structure
my_dir.files.first.acl = 'public-read'
=> allow reading of file
my_dir.files.first.public_url
=> returns public URL of file. # file must be publicly readable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment