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.

Activity

  1. tomasnajman commented on Jul 20, 2026

    @tomasnajman
    Author

    The problem has also been reported to the PHP project.
    php/php-src#22817

  2. tomasnajman commented on Jul 20, 2026

    @tomasnajman
    Author

    In PHP, this is how arrays behave and text keys that look like numbers are type-casted. A code modification is required to be able to send large attachments.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions