Created
December 12, 2018 22:20
-
-
Save mrmarcondes/e307604fa1fa324989e4fa6dec0eb3b4 to your computer and use it in GitHub Desktop.
copiar arquivos do GCS
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
storage = Google::Cloud::Storage.new( | |
project_id: ENV['GOOGLE_STORAGE_BUCKET'], | |
credentials: JSON.parse(ENV['GOOGLE_CREDENTIALS_FILE']), | |
timeout: 1_000_000 | |
) | |
bucket = storage.bucket ENV['BUCKET'] | |
files = bucket.files prefix: ENV['INTERVAL'] | |
files.each do |file| | |
downloaded = file.download | |
File.open("local-dir/#{file.name}", 'w:ASCII-8BIT') do |f| | |
f.puts(downloaded.read) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment