Sha256: d0719a06de77a3261faf674faa641e5e33582ccc628e92a7fc0e35abd37476fc

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module Kloudless
  # https://developers.kloudless.com/docs#multipart-upload
  class MultipartUpload < Model
    def self.init(account_id:, **params)
      path = "/accounts/#{account_id}/multipart"
      new(http.post(path, params: params))
    end

    def self.retrieve(account_id:, multipart_id:)
      path = "/accounts/#{account_id}/multipart/#{multipart_id}"
      new(http.get(path))
    end

    # https://developers.kloudless.com/docs#multipart-upload-upload-part
    def self.upload(account_id:, multipart_id:, part_number:, **params)
      path = "/accounts/#{account_id}/multipart/#{multipart_id}"
      params[:part_number] = part_number
      new(http.put(path, params: params))
    end

    # https://developers.kloudless.com/docs#multipart-upload-finalize-multipart-session
    def self.finalize(account_id:, multipart_id:)
      path = "/accounts/#{account_id}/multipart/#{multipart_id}/complete"
      new(http.post(path))
    end

    # https://developers.kloudless.com/docs#multipart-upload-abort-multipart-session
    def self.abort(account_id:, multipart_id:)
      path = "/accounts/#{account_id}/multipart/#{multipart_id}"
      new(http.delete(path))
    end

    class << self
      alias_method :delete, :abort
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kloudless-0.1.0 lib/kloudless/multipart_upload.rb