From 73a553ab6e7d1f318f9d2d08deba8f14d7e12f92 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Tue, 19 Mar 2024 22:58:27 +0000 Subject: [PATCH] fix(internal): make toFile use input file's options --- src/uploads.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/uploads.ts b/src/uploads.ts index 2398baf3..081827c9 100644 --- a/src/uploads.ts +++ b/src/uploads.ts @@ -102,11 +102,14 @@ export type ToFileInput = Uploadable | Exclude | AsyncIter export async function toFile( value: ToFileInput | PromiseLike, name?: string | null | undefined, - options: FilePropertyBag | undefined = {}, + options?: FilePropertyBag | undefined, ): Promise { // If it's a promise, resolve it. value = await value; + // Use the file's options if there isn't one provided + options ??= isFileLike(value) ? { lastModified: value.lastModified, type: value.type } : {}; + if (isResponseLike(value)) { const blob = await value.blob(); name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';