Skip to content

Commit

Permalink
chore(internal): codegen related update (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 6, 2024
1 parent 5681f3a commit 96bee84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
8 changes: 3 additions & 5 deletions src/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ export async function toFile(
// If it's a promise, resolve it.
value = await value;

// If we've been given a `File` we don't need to do anything
if (isFileLike(value)) {
return 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();
Expand All @@ -128,7 +126,7 @@ export async function toFile(

name ||= getName(value) ?? 'unknown_file';

if (!options?.type) {
if (!options.type) {
const type = (bits[0] as any)?.type;
if (typeof type === 'string') {
options = { ...options, type };
Expand Down
8 changes: 0 additions & 8 deletions tests/uploads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,4 @@ describe('toFile', () => {
const file = await toFile(input);
expect(file.name).toEqual('uploads.test.ts');
});

it('does not copy File objects', async () => {
const input = new File(['foo'], 'input.jsonl', { type: 'jsonl' });
const file = await toFile(input);
expect(file).toBe(input);
expect(file.name).toEqual('input.jsonl');
expect(file.type).toBe('jsonl');
});
});

0 comments on commit 96bee84

Please sign in to comment.