Class: OpenAI::Resources::Uploads::Parts

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/uploads/parts.rb,
sig/openai/resources/uploads/parts.rbs

Overview

Use Uploads to upload large files in multiple parts.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Parts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Parts.

Parameters:



58
59
60
# File 'lib/openai/resources/uploads/parts.rb', line 58

def initialize(client:)
  @client = client
end

Instance Method Details

#create(upload_id, data:, request_options: {}) ⇒ OpenAI::Models::Uploads::UploadPart

Adds a Part to an Upload object. A Part represents a chunk of bytes from the file you are trying to upload.

Each Part can be at most 64 MB, and you can add Parts until you hit the Upload maximum of 8 GB.

It is possible to add multiple Parts in parallel. You can decide the intended order of the Parts when you complete the Upload.

String, StringIO, and pathless IO inputs are sent with generic upload metadata. Use OpenAI::FilePart when you need to override the filename or content type.

Parameters:

  • upload_id (String)

    The ID of the Upload.

  • data (Pathname, StringIO, IO, String, OpenAI::FilePart)

    The chunk of bytes for this Part.

    String, StringIO, and pathless IO inputs are sent with generic upload metadata. Use OpenAI::FilePart when you need to override the filename or content type.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/openai/resources/uploads/parts.rb', line 42

def create(upload_id, params)
  parsed, options = OpenAI::Uploads::PartCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["uploads/%1$s/parts", upload_id],
    headers: {"content-type" => "multipart/form-data"},
    body: parsed,
    model: OpenAI::Uploads::UploadPart,
    security: {bearer_auth: true},
    options: options
  )
end