Skip to content

File upload fails with byte[] or InputStream due to requiring filename #284

@Jeong-Rae

Description

@Jeong-Rae

I am trying to upload a file using the OpenAI Java SDK and encountered an issue where the request fails when using InputStream, but succeeds when using Paths.get().

Use Code

public String uploadFile(MultipartFile file) { FileCreateParams params = FileCreateParams.builder() .file(file.getInputStream()) // Using InputStream .purpose(FilePurpose.ASSISTANTS) .build(); FileObject fileObject = openAIClient.files().create(params); return fileObject.id(); }

When using InputStream, the following error occurs:

400: OpenAIError{additionalProperties={error={message=The browser (or proxy) sent a request that this server could not understand., type=server_error, param=null, code=null}}} 

However, when I use Paths.get() instead, the request succeeds without issues.

Is this an expected behavior, or am I incorrectly using the SDK?

Metadata

Metadata

Assignees

No one assigned

    Labels

    apibugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions