fix(files): support filename for stream and byte-array multipart uploads - #740
fix(files): support filename for stream and byte-array multipart uploads#740bsaptarshi wants to merge 1 commit into
Conversation
|
Hi @TomerAberbach, Following up on Issue #284. I have added this PR to include default filename fallbacks (file.bin) for InputStream and byte[] overloads, plus new explicit filename overloads. This should resolve the 400 errors for anonymous uploads while remaining backward compatible. Please help review the changes! |
|
One more thing to add regarding the test failures. I confirmed they are unrelated to this PR and were already present on I ran full tests on both:
The same baseline admin/org failures appear in both runs. |
|
Can you or someone take a look at this PR? If it's no.longer required feel free to update the issue and I'll retract this. Not sure what the plan is for this one. |
Summary
Fixes multipart upload behavior for stream/byte file inputs by ensuring a filename is always present.
This addresses #284, where uploads using anonymous bytes/streams (for example, browser recordings) can fail because multipart
filenameis omitted.Changes
1) Explicit filename overloads
Added filename-aware overloads in:
com.openai.models.files.FileCreateParamscom.openai.models.containers.files.FileCreateParamsNew overloads:
file(InputStream file, String filename)file(byte[] file, String filename)2) Default filename fallback for anonymous uploads
Updated single-argument overloads to provide a safe default filename:
file(InputStream)now defaults tofile.binfile(byte[])now defaults tofile.binThis keeps backward compatibility while improving behavior for anonymous stream/bytes sources.
3) Existing behavior retained
file(Path)behavior is unchanged and continues to usepath.nameas filename.application/octet-stream.4) Tests
Added/updated tests to verify:
file.bin) is applied for single-arg stream/bytes uploadsapplication/octet-streamWhy
file(Path)already included multipart filename metadata, butfile(InputStream)andfile(byte[])previously did not.Some server-side file handling expects
filenamein multipart parts, causing failures for anonymous stream/bytes uploads.Validation
Ran targeted tests for modified models: