Module: Aliyun::Oss::Api::BucketMultiparts
- Included in:
- Client
- Defined in:
- lib/aliyun/oss/api/bucket_multiparts.rb
Instance Method Summary collapse
-
#bucket_abort_multipart(upload_id, key) ⇒ Response
Abort a Multipart Upload event.
-
#bucket_complete_multipart(upload_id, key, parts = []) ⇒ Response
Complete a Multipart Upload event.
-
#bucket_init_multipart(key, headers = {}) ⇒ Response
Initialize a Multipart Upload event, before using Multipart Upload mode to transmit data, we has to call the interface to notify the OSS initialize a Multipart Upload events.
-
#bucket_list_multiparts(options = {}) ⇒ Response
List existing opened Multipart Upload event.
-
#bucket_list_parts(upload_id, key, options = {}) ⇒ Response
List uploaded parts for Multipart Upload event.
-
#bucket_multipart_copy_upload(upload_id, key, number, options = {}) ⇒ Response
Upload a Part from an existing Object Copy data.
-
#bucket_multipart_upload(upload_id, key, number, file) ⇒ Response
Upload object in part.
Instance Method Details
#bucket_abort_multipart(upload_id, key) ⇒ Response
After abort the Multipart Upload, the Uploaded data will be deleted
When abort a Multipart Upload event, if there are still part upload belonging to this event, then theree parts will not be removed. So if there is a concurrent access, in order to release the space on the OSS completely, you need to call #bucket_abort_multipart a few times.
Abort a Multipart Upload event
121 122 123 124 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 121 def bucket_abort_multipart(upload_id, key) query = { 'uploadId' => upload_id } http.delete("/#{key}", query: query, bucket: bucket, key: key) end |
#bucket_complete_multipart(upload_id, key, parts = []) ⇒ Response
Complete a Multipart Upload event.
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 97 def bucket_complete_multipart(upload_id, key, parts = []) fail MultipartPartsEmptyError if parts.nil? || parts.empty? fail MultipartUploadIdEmptyError if upload_id.nil? query = { 'uploadId' => upload_id } body = XmlGenerator.generate_complete_multipart_xml(parts) http.post("/#{key}", query: query, body: body, bucket: bucket, key: key) end |
#bucket_init_multipart(key, headers = {}) ⇒ Response
Initialize a Multipart Upload event, before using Multipart Upload mode to transmit data, we has to call the interface to notify the OSS initialize a Multipart Upload events.
19 20 21 22 23 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 19 def bucket_init_multipart(key, headers = {}) Utils.stringify_keys!(headers) query = { 'uploads' => true } http.post("/#{key}", query: query, headers: headers, bucket: bucket, key: key) end |
#bucket_list_multiparts(options = {}) ⇒ Response
List existing opened Multipart Upload event.
139 140 141 142 143 144 145 146 147 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 139 def bucket_list_multiparts( = {}) Utils.stringify_keys!() accepted_keys = ['prefix', 'key-marker', 'upload-id-marker', 'max-uploads', 'delimiter', 'encoding-type'] query = Utils.hash_slice(, *accepted_keys) .merge('uploads' => true) http.get('/', query: query, bucket: bucket) end |
#bucket_list_parts(upload_id, key, options = {}) ⇒ Response
List uploaded parts for Multipart Upload event
161 162 163 164 165 166 167 168 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 161 def bucket_list_parts(upload_id, key, = {}) Utils.stringify_keys!() accepted_keys = ['max-parts', 'part-number-marker', 'encoding-type'] query = Utils.hash_slice(, *accepted_keys).merge('uploadId' => upload_id) http.get("/#{key}", query: query, bucket: bucket, key: key) end |
#bucket_multipart_copy_upload(upload_id, key, number, options = {}) ⇒ Response
Upload a Part from an existing Object Copy data.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 69 def bucket_multipart_copy_upload(upload_id, key, number, = {}) Utils.stringify_keys!() source_bucket = .delete('source_bucket').to_s source_key = .delete('source_key').to_s range = .delete('range') fail MultipartSourceBucketEmptyError if source_bucket.empty? fail MultipartSourceKeyEmptyError if source_key.empty? query = { 'partNumber' => number, 'uploadId' => upload_id } headers = copy_upload_headers(source_bucket, source_key, range, ) http.put("/#{key}", query: query, headers: headers, bucket: bucket, key: key) end |
#bucket_multipart_upload(upload_id, key, number, file) ⇒ Response
Upload object in part.
39 40 41 42 43 44 45 46 |
# File 'lib/aliyun/oss/api/bucket_multiparts.rb', line 39 def bucket_multipart_upload(upload_id, key, number, file) fail MultipartPartNumberEmptyError if number.nil? fail MultipartUploadIdEmptyError if upload_id.nil? || upload_id.empty? query = { 'partNumber' => number.to_s, 'uploadId' => upload_id } http.put("/#{key}", query: query, body: Utils.to_data(file), bucket: bucket, key: key) end |