Skip to content

[Bug]: Can't specify #752

@florin-botea

Description

@florin-botea

Description

Can't upload a file using

$api->files()->upload([
    'purpose' => 'user_data',
    'file'    => $temp_file,
    'expires_after' => [
        'anchor' => 'created_at',
        'seconds' => (string) now()->addDays(7)->diffInSeconds(),
    ],
]);

Because of

Steps To Reproduce

Can't upload a file using

$api->files()->upload([
    'purpose' => 'user_data',
    'file'    => $temp_file,
    'expires_after' => [
        'anchor' => 'created_at',
        'seconds' => (string) now()->addDays(7)->diffInSeconds(),
    ],
]);

Because of ValueObjects\Transporter\Payload.php:176-177 which should be

foreach ($value as $k => $nestedValue) {
    $streamBuilder->addResource($key . '[' . $k . ']', $nestedValue);
}

A temporary workaround may be:

$api->files()->upload([
    'purpose' => 'user_data',
    'file'    => $temp_file,
    'expires_after[anchor]' => 'created_at',
    'expires_after[seconds]' => (string)123
]);

OpenAI PHP Client Version

v0.19

PHP Version

8.2

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions