-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuploads.ts
More file actions
216 lines (183 loc) · 5.07 KB
/
Copy pathuploads.ts
File metadata and controls
216 lines (183 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
export class Uploads extends APIResource {
/**
* Creates a temporary signed URL that can be used to upload a file directly to the
* configured S3 bucket.
*
* @example
* ```ts
* const response = await client.uploads.createSignURL({
* contentType: 'image/png',
* scope: {
* conversationId: 'conv_01HZYFJ5P7DQ0VE8F68G5VYBAQ',
* organizationId: 'org_01HZYFG9W5V6YB5R6T6V7N9M2Q',
* type: 'conversation',
* websiteId: 'site_01HZYFH3KJ3MYHJJ3JJ6Y2RNAV',
* },
* websiteId: 'websiteId',
* });
* ```
*/
createSignURL(
body: UploadCreateSignURLParams,
options?: RequestOptions,
): APIPromise<UploadCreateSignURLResponse> {
return this._client.post('/v1/uploads/sign-url', { body, ...options, __security: {} });
}
}
/**
* Response payload containing the signed upload URL.
*/
export interface UploadCreateSignURLResponse {
/**
* Name of the S3 bucket that will receive the upload.
*/
bucket: string;
/**
* MIME type that should be used when uploading the file.
*/
contentType: string;
/**
* ISO timestamp indicating when the signed URL will expire.
*/
expiresAt: string;
/**
* Resolved object key that can be used to reference the uploaded asset.
*/
key: string;
/**
* Publicly accessible URL (or CDN URL when requested) that can be used to read the
* uploaded file.
*/
publicUrl: string;
/**
* Pre-signed URL that accepts a PUT request to upload the file to S3.
*/
uploadUrl: string;
}
export interface UploadCreateSignURLParams {
/**
* MIME type of the file to upload.
*/
contentType: string;
/**
* Defines how uploaded files should be grouped inside the S3 bucket.
*/
scope:
| UploadCreateSignURLParams.UnionMember0
| UploadCreateSignURLParams.UnionMember1
| UploadCreateSignURLParams.UnionMember2
| UploadCreateSignURLParams.UnionMember3;
websiteId: string;
/**
* Number of seconds before the signed URL expires. Defaults to 900 seconds (15
* minutes).
*/
expiresInSeconds?: number;
/**
* Optional file extension without the leading dot. Use this when providing a
* custom file name without an extension.
*/
fileExtension?: string;
/**
* Optional file name to use for the object. Invalid characters will be sanitized
* on the server side.
*/
fileName?: string;
/**
* Optional relative path used to group uploads inside the bucket. Nested paths are
* supported.
*/
path?: string;
/**
* Set to true to place the file under the /cdn prefix so it is cached by the CDN.
*/
useCdn?: boolean;
}
export namespace UploadCreateSignURLParams {
/**
* Scope uploads to a specific conversation. Files will be placed under
* /{organizationId}/{websiteId}/{conversationId}.
*/
export interface UnionMember0 {
/**
* Conversation identifier that will scope the uploaded asset.
*/
conversationId: string;
/**
* Identifier of the organization that owns the uploaded file.
*/
organizationId: string;
type: 'conversation';
/**
* Identifier of the website associated with the uploaded file.
*/
websiteId: string;
}
/**
* Scope uploads to a specific user. Files will be placed under
* /{organizationId}/{websiteId}/{userId}.
*/
export interface UnionMember1 {
/**
* Identifier of the organization that owns the uploaded file.
*/
organizationId: string;
type: 'user';
/**
* User identifier that will scope the uploaded asset.
*/
userId: string;
/**
* Identifier of the website associated with the uploaded file.
*/
websiteId: string;
}
/**
* Scope uploads to a specific contact. Files will be placed under
* /{organizationId}/{websiteId}/{contactId}.
*/
export interface UnionMember2 {
/**
* Contact identifier that will scope the uploaded asset.
*/
contactId: string;
/**
* Identifier of the organization that owns the uploaded file.
*/
organizationId: string;
type: 'contact';
/**
* Identifier of the website associated with the uploaded file.
*/
websiteId: string;
}
/**
* Scope uploads to a specific visitor. Files will be placed under
* /{organizationId}/{websiteId}/{visitorId}.
*/
export interface UnionMember3 {
/**
* Identifier of the organization that owns the uploaded file.
*/
organizationId: string;
type: 'visitor';
/**
* Visitor identifier that will scope the uploaded asset.
*/
visitorId: string;
/**
* Identifier of the website associated with the uploaded file.
*/
websiteId: string;
}
}
export declare namespace Uploads {
export {
type UploadCreateSignURLResponse as UploadCreateSignURLResponse,
type UploadCreateSignURLParams as UploadCreateSignURLParams,
};
}