Sha256: 062ac338d3d5f01ab6cf239057c8286fefa78fc6c565dd9d0b67d003aa734afb
Contents?: true
Size: 813 Bytes
Versions: 1
Compression:
Stored size: 813 Bytes
Contents
require "google/cloud/storage" require "tempfile" module OpenGCS module File STORAGE_OPTION_KEYS = %i( project_id credentials scope retries timeout endpoint project keyfile ) DOWNLOAD_OPTION_KEYS = %i( verify encryption_key range skip_decompress ) OPTION_KEYS = STORAGE_OPTION_KEYS + DOWNLOAD_OPTION_KEYS def self.download(bucket, filename, **options) storage = Google::Cloud::Storage.new(**options.select { |o, v| v && STORAGE_OPTION_KEYS.include?(o) }) file = storage.bucket(bucket, skip_lookup: true).file(filename, skip_lookup: true) tf = Tempfile.open(["open-gcs"]) file.download(tf.path, **options.select { |o, v| v && DOWNLOAD_OPTION_KEYS.include?(o) }) tf end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
open-gcs-0.1.0 | lib/open-gcs/file.rb |