Method: HP::Cloud::RemoteResource#object_head

Defined in:
lib/hpcloud/remote_resource.rb

#object_headObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/hpcloud/remote_resource.rb', line 139

def object_head()
  begin
    return true unless @size.nil?
    @size = 0
    data = @storage.head_object(@container, @path)
    if data.nil? || data.headers.nil?
      @cstatus = CliStatus.new("Cannot find object ':#{@container}/#{@path}'.", :not_found)
      return false
    end
    return parse_object_headers(data.headers)
  rescue Fog::Storage::HP::NotFound => error
    @cstatus = CliStatus.new("Cannot find object ':#{@container}/#{@path}'.", :not_found)
    return false
  rescue Excon::Errors::Forbidden => e
    resp = ErrorResponse.new(e)
    @cstatus = CliStatus.new(resp.error_string, :permission_denied)
    return false
  rescue Fog::HP::Errors::Forbidden => error
    @cstatus = CliStatus.new("Permission denied trying to access '#{@fname}'.", :permission_denied)
    return false
  rescue Exception => error
    @cstatus = CliStatus.new("Error oh reading '#{@fname}': " + error.to_s, :general_error)
    return false
  end
end