You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The client accepts a variety of types for file upload parameters:
96
-
97
-
- Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream`
98
-
- Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array`
95
+
* Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream`
96
+
* Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array`
99
97
100
98
### Metadata
101
99
102
100
You can configure metadata when uploading a file:
103
-
104
101
```typescript
105
102
const file:Uploadable.WithMetadata= {
106
103
data: createReadStream("path/to/file"),
107
-
filename: "my-file", // optional
104
+
filename: "my-file", // optional
108
105
contentType: "audio/mpeg", // optional
109
-
contentLength: 1949, // optional
106
+
contentLength: 1949, // optional
110
107
};
111
108
```
112
109
113
110
Alternatively, you can upload a file directly from a file path:
114
-
115
111
```typescript
116
-
const file:Uploadable.FromPath= {
112
+
const file:Uploadable.FromPath= {
117
113
path: "path/to/file",
118
-
filename: "my-file", // optional
119
-
contentType: "audio/mpeg", // optional
120
-
contentLength: 1949, // optional
114
+
filename: "my-file", // optional
115
+
contentType: "audio/mpeg", // optional
116
+
contentLength: 1949, // optional
121
117
};
122
118
```
123
119
124
120
The metadata is used to set the `Content-Length`, `Content-Type`, and `Content-Disposition` headers. If not provided, the client will attempt to determine them automatically.
125
121
For example, `fs.ReadStream` has a `path` property which the SDK uses to retrieve the file size from the filesystem without loading it into memory.
126
122
123
+
127
124
## Binary Response
128
125
129
126
You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
0 commit comments