Class: Bosh::Blobstore::Sha1VerifiableBlobstoreClient

Inherits:
BaseClient show all
Extended by:
Forwardable
Defined in:
lib/blobstore_client/sha1_verifiable_blobstore_client.rb

Constant Summary

Constants inherited from Client

Client::PROVIDER_NAMES, Client::VERSION

Instance Method Summary collapse

Methods inherited from BaseClient

#create, #delete, #exists?

Methods inherited from Client

create, safe_create

Constructor Details

#initialize(client) ⇒ Sha1VerifiableBlobstoreClient

Returns a new instance of Sha1VerifiableBlobstoreClient.



9
10
11
# File 'lib/blobstore_client/sha1_verifiable_blobstore_client.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#get(id, file = nil, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/blobstore_client/sha1_verifiable_blobstore_client.rb', line 13

def get(id, file = nil, options = {})
  if options.has_key?(:sha1)
    expected_sha1 = options[:sha1]
    raise ArgumentError, 'sha1 must not be nil' unless expected_sha1
  end

  result_file = @client.get(id, file, options)

  if expected_sha1
    # Blobstore clients either modify passed in file
    # or return new temporary file
    check_sha1(expected_sha1, file || result_file)
  end

  result_file
end