Class: Aliyun::Oss::Struct::Multipart

Inherits:
Base
  • Object
show all
Defined in:
lib/aliyun/oss/struct/multipart.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Aliyun::Oss::Struct::Base

Instance Attribute Details

#bucketObject

Bucket name of the Multipart Upload Event



12
13
14
# File 'lib/aliyun/oss/struct/multipart.rb', line 12

def bucket
  @bucket
end

#clientObject

reference to client



18
19
20
# File 'lib/aliyun/oss/struct/multipart.rb', line 18

def client
  @client
end

#initiatedObject

Initiation time of the Multipart Upload Event



15
16
17
# File 'lib/aliyun/oss/struct/multipart.rb', line 15

def initiated
  @initiated
end

#keyObject

Object name of the Multipart Upload Event



9
10
11
# File 'lib/aliyun/oss/struct/multipart.rb', line 9

def key
  @key
end

#upload_idObject

UUID for the Multipart Upload Event



6
7
8
# File 'lib/aliyun/oss/struct/multipart.rb', line 6

def upload_id
  @upload_id
end

Instance Method Details

#aborttrue

Note:

After abort the Multipart Upload, the Uploaded data will be deleted

Note:

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 Multipart Upload Event

Returns:

  • (true)

Raises:

See Also:



96
97
98
# File 'lib/aliyun/oss/struct/multipart.rb', line 96

def abort
  !!client.bucket_abort_multipart(upload_id, key)
end

#complete(parts = []) ⇒ Struct::Object

Complete Multipart Upload Event

Parameters:

  • parts (Array<Aliyun::Oss::Multipart:Part>) (defaults to: [])

    parts

Returns:

Raises:

See Also:



80
81
82
83
84
85
86
# File 'lib/aliyun/oss/struct/multipart.rb', line 80

def complete(parts = [])
  resp = client.bucket_complete_multipart(upload_id, key, parts)
  keys = %w(CompleteMultipartUploadResult)
  Struct::Object.new(
    Utils.dig_value(resp.parsed_response, *keys).merge(client: client)
  )
end

#copy(*args) ⇒ true

Copy exsting object to Multipart Upload Event

Parameters:

  • number (Integer)

    the part number, Range in 1~10000.

  • options (Hash)

    options

Returns:

  • (true)

Raises:

See Also:



48
49
50
# File 'lib/aliyun/oss/struct/multipart.rb', line 48

def copy(*args)
  !!client.bucket_multipart_copy_upload(*args.unshift(upload_id, key))
end

#list_parts(options = {}) ⇒ Array<Aliyun::Oss::Struct::Part>

List uploaded parts for the Multipart Upload Event

Parameters:

  • options (Hash) (defaults to: {})

    options

Returns:

See Also:



61
62
63
64
65
66
67
68
69
# File 'lib/aliyun/oss/struct/multipart.rb', line 61

def list_parts(options = {})
  result = client.bucket_list_parts(upload_id, key, options)
           .parsed_response

  parts_keys = %w(ListPartsResult Part)
  Utils.wrap(Utils.dig_value(result, *parts_keys)).map do |part|
    Struct::Part.new(part)
  end
end

#upload(*args) ⇒ HTTParty::Response::Headers

Upload part to Multipart Upload Event

Parameters:

  • number (Integer)

    the part number, Range in 1~10000.

  • file (File, bin data)

    the upload data

Returns:

  • (HTTParty::Response::Headers)

Raises:

  • (RequestError)
  • (MultipartPartNumberEmptyError)
  • (MultipartUploadIdEmptyError)

See Also:



34
35
36
# File 'lib/aliyun/oss/struct/multipart.rb', line 34

def upload(*args)
  client.bucket_multipart_upload(*args.unshift(upload_id, key)).headers
end