Method: HP::Cloud::RemoteResource#write

Defined in:
lib/hpcloud/remote_resource.rb

#write(chunk) ⇒ Object



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/hpcloud/remote_resource.rb', line 237

def write(chunk)
  if @write_io.nil?
    begin
      @read_io, @write_io = IO.pipe
      @write_thread = Thread.new {
        @storage.put_object(@container, @destination, {}, @options) {
          @read_io.read
        }
      }
    rescue Exception => e
      @cstatus = CliStatus.new("Error writing object creating thread.")
      return false
    end
  end
  begin
    @write_io.write(chunk)
  rescue Exception => e
    @cstatus = CliStatus.new("Error writing object.")
    return false
  end
  return true
end