Class: OpenAI::Resources::Uploads
- Inherits:
-
Object
- Object
- OpenAI::Resources::Uploads
- Defined in:
- lib/openai/resources/uploads.rb,
lib/openai/resources/uploads/parts.rb,
sig/openai/resources/uploads.rbs,
sig/openai/resources/uploads/parts.rbs
Overview
Use Uploads to upload large files in multiple parts.
Defined Under Namespace
Classes: Parts
Instance Attribute Summary collapse
-
#parts ⇒ OpenAI::Resources::Uploads::Parts
readonly
Use Uploads to upload large files in multiple parts.
Instance Method Summary collapse
-
#cancel(upload_id, request_options: {}) ⇒ OpenAI::Models::Upload
Cancels the Upload.
-
#complete(upload_id, part_ids:, md5: nil, request_options: {}) ⇒ OpenAI::Models::Upload
Completes the Upload.
- #create(bytes:, filename:, mime_type:, purpose:, expires_after: nil, request_options: {}) ⇒ OpenAI::Models::Upload
-
#initialize(client:) ⇒ Uploads
constructor
private
A new instance of Uploads.
Constructor Details
#initialize(client:) ⇒ Uploads
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 Uploads.
146 147 148 149 |
# File 'lib/openai/resources/uploads.rb', line 146 def initialize(client:) @client = client @parts = OpenAI::Resources::Uploads::Parts.new(client: client) end |
Instance Attribute Details
#parts ⇒ OpenAI::Resources::Uploads::Parts (readonly)
Use Uploads to upload large files in multiple parts.
9 10 11 |
# File 'lib/openai/resources/uploads.rb', line 9 def parts @parts end |
Instance Method Details
#cancel(upload_id, request_options: {}) ⇒ OpenAI::Models::Upload
Cancels the Upload. No Parts may be added after an Upload is cancelled.
Returns the Upload object with status cancelled.
88 89 90 91 92 93 94 95 96 |
# File 'lib/openai/resources/uploads.rb', line 88 def cancel(upload_id, params = {}) @client.request( method: :post, path: ["uploads/%1$s/cancel", upload_id], model: OpenAI::Upload, security: {bearer_auth: true}, options: params[:request_options] ) end |
#complete(upload_id, part_ids:, md5: nil, request_options: {}) ⇒ OpenAI::Models::Upload
Completes the Upload.
Within the returned Upload object, there is a nested File object that is ready to use in the rest of the platform.
You can specify the order of the Parts by passing in an ordered list of the Part IDs.
The number of bytes uploaded upon completion must match the number of bytes
initially specified when creating the Upload object. No Parts may be added after
an Upload is completed. Returns the Upload object with status completed,
including an additional file property containing the created usable File
object.
131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/openai/resources/uploads.rb', line 131 def complete(upload_id, params) parsed, = OpenAI::UploadCompleteParams.dump_request(params) @client.request( method: :post, path: ["uploads/%1$s/complete", upload_id], body: parsed, model: OpenAI::Upload, security: {bearer_auth: true}, options: ) end |
#create(bytes:, filename:, mime_type:, purpose:, expires_after: nil, request_options: {}) ⇒ OpenAI::Models::Upload
Creates an intermediate Upload object that you can add Parts to. Currently, an Upload can accept at most 8 GB in total and expires after an hour after you create it.
Once you complete the Upload, we will create a File object that contains all the parts you uploaded. This File is usable in the rest of our platform as a regular File object.
For certain purpose values, the correct mime_type must be specified. Please
refer to documentation for the
supported MIME types for your use case.
For guidance on the proper filename extensions for each purpose, please follow the documentation on creating a File.
Returns the Upload object with status pending.
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/openai/resources/uploads.rb', line 62 def create(params) parsed, = OpenAI::UploadCreateParams.dump_request(params) @client.request( method: :post, path: "uploads", body: parsed, model: OpenAI::Upload, security: {bearer_auth: true}, options: ) end |