Skip to content

Instantly share code, notes, and snippets.

@smashwilson
Created October 17, 2014 11:59
Show Gist options
  • Save smashwilson/9ea2a48909980e6eb04d to your computer and use it in GitHub Desktop.
Save smashwilson/9ea2a48909980e6eb04d to your computer and use it in GitHub Desktop.
Pagination in Fog
require 'pp'
storage = Fog::Storage.new(
provider: :rackspace,
rackspace_username: ENV['RAX_USERNAME'],
rackspace_api_key: ENV['RAX_API_KEY'],
rackspace_region: :dfw
)
d = storage.directories.get('big-container')
# This will only return you the first page of results - by default, 10k.
page = d.files.all
puts "The first page of results:"
pp page
# This will iterate over everything.
puts "All results:"
d.files.each do |f|
puts " * #{f.key}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment