Class: Uplink::PartUpload
- Inherits:
-
Object
- Object
- Uplink::PartUpload
- Defined in:
- lib/uplink/upload.rb
Instance Method Summary collapse
- #abort ⇒ Object
- #commit ⇒ Object
- #info ⇒ Object
-
#initialize(part_upload_result) ⇒ PartUpload
constructor
A new instance of PartUpload.
- #set_etag(etag) ⇒ Object
- #write(bytes, length) ⇒ Object
Constructor Details
#initialize(part_upload_result) ⇒ PartUpload
Returns a new instance of PartUpload.
82 83 84 |
# File 'lib/uplink/upload.rb', line 82 def initialize(part_upload_result) @part_upload = part_upload_result[:part_upload] end |
Instance Method Details
#abort ⇒ Object
119 120 121 122 123 124 |
# File 'lib/uplink/upload.rb', line 119 def abort error = UplinkLib.uplink_part_upload_abort(@part_upload) ErrorUtil.handle_error(error) ensure UplinkLib.uplink_free_error(error) if error end |
#commit ⇒ Object
112 113 114 115 116 117 |
# File 'lib/uplink/upload.rb', line 112 def commit error = UplinkLib.uplink_part_upload_commit(@part_upload) ErrorUtil.handle_error(error) ensure UplinkLib.uplink_free_error(error) if error end |
#info ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'lib/uplink/upload.rb', line 126 def info result = UplinkLib.uplink_part_upload_info(@part_upload) ErrorUtil.handle_result_error(result) UploadPart.new(result) ensure UplinkLib.uplink_free_part_result(result) if result end |
#set_etag(etag) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/uplink/upload.rb', line 105 def set_etag(etag) error = UplinkLib.uplink_part_upload_set_etag(@part_upload, etag) ErrorUtil.handle_error(error) ensure UplinkLib.uplink_free_error(error) if error end |
#write(bytes, length) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/uplink/upload.rb', line 86 def write(bytes, length) raise ArgumentError, 'bytes argument is nil' if bytes.nil? if bytes.is_a?(Array) && bytes.first.is_a?(Integer) mem_bytes = FFI::MemoryPointer.new(:uint8, length) mem_bytes.write_array_of_uint8(bytes) else mem_bytes = bytes end result = UplinkLib.uplink_part_upload_write(@part_upload, mem_bytes, length) abort unless result[:error].null? ErrorUtil.handle_result_error(result) result[:bytes_written] ensure UplinkLib.uplink_free_write_result(result) if result end |