Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added filename support for the file payload#416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
apc-harold wants to merge1 commit intoopenai-php:main
base:main
Choose a base branch
Loading
fromapc-harold:main

Conversation

@apc-harold
Copy link

What:

  • Bug Fix
  • New Feature

Description:

When uploading a file using:

$client->files()->upload([    'purpose' => $purpose,    'file' => $file,]);

The uploaded file is automatically namedNyholm-Psr7-Zval:, which causes issues because it doesn't have a file extension. This prevents the file from being attached to an assistant.

The proposed changes allow for a file name to be provided by instead passing an array value for the file key:

$client->files()->upload([    'purpose' => $purpose,    'file' => [        'data' => $file,        'fileName' => $fileName,    ],]);

@gehrisandro
Copy link
Collaborator

Hi@apc-harold

I am not able to reproduce the issue. When I upload a file, the filename is set properly.

Could you please provided a full example or a demo repository which reproduces the issue?

@apc-harold
Copy link
Author

Hi@gehrisandro,

Thanks for checking it out!

I'm quite busy at the moment so won't be able to provide an example, but:

  • Using Laravel, using $file->get() to retrieve the file
  • Using thebeta version

I'll maybe have some time on w/s 17th, so will make a reminder to come back and make an example if it's still here.

@DennisBirkholz
Copy link

DennisBirkholz commentedJun 27, 2024
edited
Loading

I stumbled on the same problem:
it is not easily possible to upload string data as a file, because no filename (or an invalid filename) gets sent that is missing the ".jsonl" extension.

This may also be remedied by adding the following code to the file upload example:

$jsonlData ="{...}\n{...}";$response =$client->files()->upload(['purpose' =>'fine-tune','file' => \GuzzleHttp\Psr7\Utils::streamFor($jsonlData, ["metadata" => ["uri" =>"upload.jsonl"]]),    ]);
olimarferraz and qwertyquest reacted with hooray emojiolimarferraz reacted with rocket emoji

@olimarferraz
Copy link

@DennisBirkholz thanks! Works for me. I'm using the Laravel driver and was stuck in how properly handle this uploads.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@apc-harold@gehrisandro@DennisBirkholz@olimarferraz

[8]ページ先頭

©2009-2025 Movatter.jp