Created
October 17, 2014 11:59
-
-
Save smashwilson/9ea2a48909980e6eb04d to your computer and use it in GitHub Desktop.
Pagination in Fog
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
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