Skip to content

Commit 15880d7

Browse files
fix(internal): make toFile use input file's options (#727)
1 parent d4673f1 commit 15880d7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: src/uploads.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ export type ToFileInput = Uploadable | Exclude<BlobLikePart, string> | AsyncIter
102102
export async function toFile(
103103
value: ToFileInput | PromiseLike<ToFileInput>,
104104
name?: string | null | undefined,
105-
options: FilePropertyBag | undefined = {},
105+
options?: FilePropertyBag | undefined,
106106
): Promise<FileLike> {
107107
// If it's a promise, resolve it.
108108
value = await value;
109109

110+
// Use the file's options if there isn't one provided
111+
options ??= isFileLike(value) ? { lastModified: value.lastModified, type: value.type } : {};
112+
110113
if (isResponseLike(value)) {
111114
const blob = await value.blob();
112115
name ||= new URL(value.url).pathname.split(/[\\/]/).pop() ?? 'unknown_file';

0 commit comments

Comments
 (0)