Skip to content

Instantly share code, notes, and snippets.

@mrmarcondes
Created December 12, 2018 22:20
Show Gist options
  • Save mrmarcondes/e307604fa1fa324989e4fa6dec0eb3b4 to your computer and use it in GitHub Desktop.
Save mrmarcondes/e307604fa1fa324989e4fa6dec0eb3b4 to your computer and use it in GitHub Desktop.
copiar arquivos do GCS
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