go/resources/uploads/methods/cancel/index.md +0 −176 deleted
File Deleted View Diff
1## Cancel upload
2
3`client.Uploads.Cancel(ctx, uploadID) (*Upload, error)`
4
5**post** `/uploads/{upload_id}/cancel`
6
7Cancels the Upload. No Parts may be added after an Upload is cancelled.
8
9Returns the Upload object with status `cancelled`.
10
11### Parameters
12
13- `uploadID string`
14
15### Returns
16
17- `type Upload struct{…}`
18
19 The Upload object can accept byte chunks in the form of Parts.
20
21 - `ID string`
22
23 The Upload unique identifier, which can be referenced in API endpoints.
24
25 - `Bytes int64`
26
27 The intended number of bytes to be uploaded.
28
29 - `CreatedAt int64`
30
31 The Unix timestamp (in seconds) for when the Upload was created.
32
33 - `ExpiresAt int64`
34
35 The Unix timestamp (in seconds) for when the Upload will expire.
36
37 - `Filename string`
38
39 The name of the file to be uploaded.
40
41 - `Object Upload`
42
43 The object type, which is always "upload".
44
45 - `const UploadUpload Upload = "upload"`
46
47 - `Purpose string`
48
49 The intended purpose of the file. [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose) for acceptable values.
50
51 - `Status UploadStatus`
52
53 The status of the Upload.
54
55 - `const UploadStatusPending UploadStatus = "pending"`
56
57 - `const UploadStatusCompleted UploadStatus = "completed"`
58
59 - `const UploadStatusCancelled UploadStatus = "cancelled"`
60
61 - `const UploadStatusExpired UploadStatus = "expired"`
62
63 - `File FileObject`
64
65 The `File` object represents a document that has been uploaded to OpenAI.
66
67 - `ID string`
68
69 The file identifier, which can be referenced in the API endpoints.
70
71 - `Bytes int64`
72
73 The size of the file, in bytes.
74
75 - `CreatedAt int64`
76
77 The Unix timestamp (in seconds) for when the file was created.
78
79 - `Filename string`
80
81 The name of the file.
82
83 - `Object File`
84
85 The object type, which is always `file`.
86
87 - `const FileFile File = "file"`
88
89 - `Purpose FileObjectPurpose`
90
91 The intended purpose of the file. Supported values are `assistants`, `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`, `vision`, and `user_data`.
92
93 - `const FileObjectPurposeAssistants FileObjectPurpose = "assistants"`
94
95 - `const FileObjectPurposeAssistantsOutput FileObjectPurpose = "assistants_output"`
96
97 - `const FileObjectPurposeBatch FileObjectPurpose = "batch"`
98
99 - `const FileObjectPurposeBatchOutput FileObjectPurpose = "batch_output"`
100
101 - `const FileObjectPurposeFineTune FileObjectPurpose = "fine-tune"`
102
103 - `const FileObjectPurposeFineTuneResults FileObjectPurpose = "fine-tune-results"`
104
105 - `const FileObjectPurposeVision FileObjectPurpose = "vision"`
106
107 - `const FileObjectPurposeUserData FileObjectPurpose = "user_data"`
108
109 - `Status FileObjectStatus`
110
111 Deprecated. The current status of the file, which can be either `uploaded`, `processed`, or `error`.
112
113 - `const FileObjectStatusUploaded FileObjectStatus = "uploaded"`
114
115 - `const FileObjectStatusProcessed FileObjectStatus = "processed"`
116
117 - `const FileObjectStatusError FileObjectStatus = "error"`
118
119 - `ExpiresAt int64`
120
121 The Unix timestamp (in seconds) for when the file will expire.
122
123 - `StatusDetails string`
124
125 Deprecated. For details on why a fine-tuning training file failed validation, see the `error` field on `fine_tuning.job`.
126
127### Example
128
129```go
130package main
131
132import (
133 "context"
134 "fmt"
135
136 "github.com/openai/openai-go"
137 "github.com/openai/openai-go/option"
138)
139
140func main() {
141 client := openai.NewClient(
142 option.WithAPIKey("My API Key"),
143 )
144 upload, err := client.Uploads.Cancel(context.TODO(), "upload_abc123")
145 if err != nil {
146 panic(err.Error())
147 }
148 fmt.Printf("%+v\n", upload.ID)
149}
150```
151
152#### Response
153
154```json
155{
156 "id": "id",
157 "bytes": 0,
158 "created_at": 0,
159 "expires_at": 0,
160 "filename": "filename",
161 "object": "upload",
162 "purpose": "purpose",
163 "status": "pending",
164 "file": {
165 "id": "id",
166 "bytes": 0,
167 "created_at": 0,
168 "filename": "filename",
169 "object": "file",
170 "purpose": "assistants",
171 "status": "uploaded",
172 "expires_at": 0,
173 "status_details": "status_details"
174 }
175}
176```