Skip to content

Unable to send large attachment: LargeFileUploadTask and headers #1794

Description

@tomasnajman

Unable to upload large attachment. In the file Microsoft\Kiota\Abstractions\RequestHeaders, the array_keys function is used, which casts a string to a number. PHP 8.4 on x64 does this.

In the getAll method, it is cast and then an error is returned: Since guzzlehttp/psr7 2.11: Passing int to GuzzleHttp\Psr7\Request::__construct() is deprecated; guzzlehttp/psr7 3.0 requires string|string[].

Instead of array_keys, you must use foreach.

A method with array_keys that casts string to int.

public function getAll(): array
{
    $result = [];
    foreach ($this->headers as $key => $value) {
        $result[$key] = array_keys($value);
    }
    return $result;
}

A method with foreach that works.

public function getAll(): array
{
    $result = [];
    foreach ($this->headers as $key => $value) {
        foreach ($value as $k => $v) {
            $result[$key][] = strval($k);
        }
        //$result[$key] = array_keys($value);
    }
    return $result;
}

After this change, sending large attachments works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions