Sha256: af302594557b68a495e55877546d66034b2b4776f80b5b696df3ae797dbfa2aa

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

require "stashify/file"

module Stashify
  class File
    module Microsoft
      module Azure
        module Storage
          class Blob < Stashify::File
            def initialize(client:, container:, path:)
              @client = client
              @container = container
              super(path: path)
            end

            def contents
              _, content = @client.get_blob(@container.name, path)
              content
            end

            def write(contents)
              @client.create_block_blob(@container.name, path, contents)
            end

            def exists?
              @client.get_blob(@container.name, path)
            rescue ::Azure::Core::Http::HTTPError => e
              raise unless e.status_code == 404
            end

            def delete
              @client.delete_blob(@container.name, path)
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stashify-microsoft-azure-storage-blob-1.0.0 lib/stashify/file/microsoft/azure/storage/blob.rb