3.9.0

(feat): Add support for the Uploadable.FromPath and Uploadable.WithMetadata types to upload files with metadata to multipart-form endpoints.

Users can configure metadata when uploading a file to a multipart-form upload endpoint using the Uploadable.WithMetadata type:

1import { createReadStream } from "fs";
2
3await client.upload({
4 file: {
5 data: createReadStream("path/to/file"),
6 filename: "my-file",
7 contentType: "audio/mpeg",
8 },
9 otherField: "other value",
10});

The filename, contentType, and contentLength properties are optional.

Alternatively, users can use the Uploadable.FromPath type to upload directly from a file path:

1await client.upload({
2 file: {
3 path: "path/to/file",
4 filename: "my-file",
5 contentType: "audio/mpeg",
6 },
7 otherField: "other value",
8});

The metadata is used to set the Content-Type and Content-Disposition headers. If not provided, the client will attempt to determine them automatically.