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`
85
+
* Stream types: `fs.ReadStream`, `stream.Readable`, and `ReadableStream`
86
+
* Buffered types: `Buffer`, `Blob`, `File`, `ArrayBuffer`, `ArrayBufferView`, and `Uint8Array`
99
87
100
88
### Metadata
101
89
102
90
You can configure metadata when uploading a file:
103
-
104
91
```typescript
105
92
const file:Uploadable.WithMetadata= {
106
93
data: createReadStream("path/to/file"),
107
-
filename: "my-file", // optional
94
+
filename: "my-file", // optional
108
95
contentType: "audio/mpeg", // optional
109
-
contentLength: 1949, // optional
96
+
contentLength: 1949, // optional
110
97
};
111
98
```
112
99
113
100
Alternatively, you can upload a file directly from a file path:
114
-
115
101
```typescript
116
-
const file:Uploadable.FromPath= {
102
+
const file:Uploadable.FromPath= {
117
103
path: "path/to/file",
118
-
filename: "my-file", // optional
119
-
contentType: "audio/mpeg", // optional
120
-
contentLength: 1949, // optional
104
+
filename: "my-file", // optional
105
+
contentType: "audio/mpeg", // optional
106
+
contentLength: 1949, // optional
121
107
};
122
108
```
123
109
124
110
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
111
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
112
113
+
127
114
## Binary Response
128
115
129
116
You can consume binary data from endpoints using the `BinaryResponse` type which lets you choose how to consume the data:
0 commit comments