src/Tus/Client.php
public function create(string $key) : string
    {
        $headers = [
            'Upload-Length' => $this->fileSize,
            'Upload-Key' => $key,
            'Upload-Checksum' => $this->getUploadChecksumHeader(),
            'Upload-Metadata' => 'filename ' . base64_encode($this->fileName),
        ];

        if ($this->isPartial()) {
            $headers += ['Upload-Concat' => 'partial'];
        }

        $response = $this->getClient()->post($this->apiPath, [
            'headers' => $headers,
        ]);

        $statusCode = $response->getStatusCode();

        if (HttpResponse::HTTP_CREATED !== $statusCode) {
            throw new FileException('Unable to create resource.');
        }

        $uploadLocation = current($response->getHeader('location'));

        $this->getCache()->set($this->getKey(), [
            'location' => $uploadLocation,
            'expires_at' => Carbon::now()->addSeconds($this->getCache()->getTtl())->format($this->getCache()::RFC_7231),
        ]);

        return $uploadLocation;
    }
public function create(string $key) : string
    {
        $headers = [
            'Upload-Length' => $this->fileSize,
            'Upload-Key' => $key,
            'Upload-Checksum' => $this->getUploadChecksumHeader(),
            'Upload-Metadata' => 'filename ' . base64_encode($this->fileName),
        ];

        if ($this->isPartial()) {
            $headers += ['Upload-Concat' => 'partial'];
        }

        $response = $this->getClient()->post($this->apiPath, [
            'headers' => $headers,
        ]);

        $statusCode = $response->getStatusCode();

        if (HttpResponse::HTTP_CREATED !== $statusCode) {
            throw new FileException('Unable to create resource.');
        }

        $uploadLocation = current($response->getHeader('location'));

        $this->getCache()->set($this->getKey(), [
            'location' => $uploadLocation,
            'expires_at' => Carbon::now()->addSeconds($this->getCache()->getTtl())->format($this->getCache()::RFC_7231),
        ]);

        return $uploadLocation;
    }
public function create ( string $ key ) : string { $ headers = [ 'Upload-Length' => $ this -> fileSize , 'Upload-Key' => $ key , 'Upload-Checksum' => $ this -> getUploadChecksumHeader ( ) , 'Upload-Metadata' => 'filename ' . base64_encode ( $ this -> fileName ) , ] ; if ( $ this -> isPartial ( ) ) { $ headers += [ 'Upload-Concat' => 'partial' ] ; } $ response = $ this -> getClient ( ) -> post ( $ this -> apiPath , [ 'headers' => $ headers , ] ) ; $ statusCode = $ response -> getStatusCode ( ) ; if ( HttpResponse :: HTTP_CREATED !== $ statusCode ) { throw new FileException ( 'Unable to create resource.' ) ; } $ uploadLocation = current ( $ response -> getHeader ( 'location' ) ) ; $ this -> getCache ( ) -> set ( $ this -> getKey ( ) , [ 'location' => $ uploadLocation , 'expires_at' => Carbon :: now ( ) -> addSeconds ( $ this -> getCache ( ) -> getTtl ( ) ) -> format ( $ this -> getCache ( ) :: RFC_7231 ) , ] ) ; return $ uploadLocation ; }
Create resource with POST request.

@param string $key

@throws FileException

@return string
Create resource with POST request .