azure-storage-file/src/File/FileRestProxy.php
private function multiplePutRangeConcurrentAsync(
        $share,
        $path,
        $content,
        Range $range,
        PutFileRangeOptions $options = null,
        $useTransactionalMD5 = false
    ) {
        $queryParams  = array();
        $headers      = array();
        $path         = $this->createPath($share, $path);
        $selfInstance = $this;

        if ($options == null) {
            $options = new PutFileRangeOptions();
        }

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            'range'
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_WRITE,
            'Update'
        );

        $counter = 0;
        //create the generator for requests.
        $generator = function () use (
            $headers,
            $path,
            $content,
            &$counter,
            $queryParams,
            $range,
            $useTransactionalMD5,
            $selfInstance
        ) {
            $size = 0;
            $chunkContent = '';
            $start = 0;

            do {
                $start = $range->getStart() + (Resources::MB_IN_BYTES_4 * $counter++);
                $end = $range->getEnd();
                if ($end != null && $start >= $end) {
                    return null;
                }
                $chunkContent = $content->read(Resources::MB_IN_BYTES_4);
                $size = strlen($chunkContent);
                if ($size == 0) {
                    return null;
                }
            } while (Utilities::allZero($chunkContent));

            $chunkRange = new Range($start);
            $chunkRange->setLength($size);

            $selfInstance->addOptionalHeader(
                $headers,
                Resources::X_MS_RANGE,
                $chunkRange->getRangeString()
            );

            $this->addOptionalHeader(
                $headers,
                Resources::CONTENT_LENGTH,
                $size
            );

            if ($useTransactionalMD5) {
                $contentMD5 = base64_encode(md5($chunkContent, true));
                $this->addOptionalHeader(
                    $headers,
                    Resources::CONTENT_MD5,
                    $contentMD5
                );
            }

            return $selfInstance->createRequest(
                Resources::HTTP_PUT,
                $headers,
                $queryParams,
                array(),
                $path,
                LocationMode::PRIMARY_ONLY,
                $chunkContent
            );
        };

        return $this->sendConcurrentAsync(
            $generator,
            Resources::STATUS_CREATED,
            $options
        );
    }
private function multiplePutRangeConcurrentAsync(
        $share,
        $path,
        $content,
        Range $range,
        PutFileRangeOptions $options = null,
        $useTransactionalMD5 = false
    ) {
        $queryParams  = array();
        $headers      = array();
        $path         = $this->createPath($share, $path);
        $selfInstance = $this;

        if ($options == null) {
            $options = new PutFileRangeOptions();
        }

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_COMP,
            'range'
        );

        $this->addOptionalQueryParam(
            $queryParams,
            Resources::QP_TIMEOUT,
            $options->getTimeout()
        );

        $this->addOptionalHeader(
            $headers,
            Resources::X_MS_WRITE,
            'Update'
        );

        $counter = 0;
        //create the generator for requests.
        $generator = function () use (
            $headers,
            $path,
            $content,
            &$counter,
            $queryParams,
            $range,
            $useTransactionalMD5,
            $selfInstance
        ) {
            $size = 0;
            $chunkContent = '';
            $start = 0;

            do {
                $start = $range->getStart() + (Resources::MB_IN_BYTES_4 * $counter++);
                $end = $range->getEnd();
                if ($end != null && $start >= $end) {
                    return null;
                }
                $chunkContent = $content->read(Resources::MB_IN_BYTES_4);
                $size = strlen($chunkContent);
                if ($size == 0) {
                    return null;
                }
            } while (Utilities::allZero($chunkContent));

            $chunkRange = new Range($start);
            $chunkRange->setLength($size);

            $selfInstance->addOptionalHeader(
                $headers,
                Resources::X_MS_RANGE,
                $chunkRange->getRangeString()
            );

            $this->addOptionalHeader(
                $headers,
                Resources::CONTENT_LENGTH,
                $size
            );

            if ($useTransactionalMD5) {
                $contentMD5 = base64_encode(md5($chunkContent, true));
                $this->addOptionalHeader(
                    $headers,
                    Resources::CONTENT_MD5,
                    $contentMD5
                );
            }

            return $selfInstance->createRequest(
                Resources::HTTP_PUT,
                $headers,
                $queryParams,
                array(),
                $path,
                LocationMode::PRIMARY_ONLY,
                $chunkContent
            );
        };

        return $this->sendConcurrentAsync(
            $generator,
            Resources::STATUS_CREATED,
            $options
        );
    }
Creates promise to write range of bytes (more than 4MB) to a file.

@param  string                   $share   The share name.
@param  string                   $path    The path of the file.
@param  StreamInterface          $content The content to be uploaded.
@param  Range                    $range   The range in the file to be put.
4MB length min.
@param  PutFileRangeOptions|null $options The optional parameters.
@param  boolean                  $useTransactionalMD5
Optional. Whether enable transactional
MD5 validation during uploading.

@return \GuzzleHttp\Promise\PromiseInterface

@see https://docs.microsoft.com/en-us/rest/api/storageservices/put-range