Got HTTP 308 when trying to upload a file to Nuxeo server

I want to upload in chunks a file to a Nuxeo server :

    ...
    use SymfonyContractsHttpClientHttpClientInterface;
    ...
    public function __construct(HttpClientInterface $client)
    {
        $this->client = $client;
    }
    ...
    $nbChunks = 5;
    for($chunkIdx = 0 ; $chunkIdx < $nbChunks ; $chunkIdx++) {
       $uploadResponse = $this->client->request('POST', 'http://192.168.128.101:8080/nuxeo/api/v1/upload/' . $nuxeoBatchId . '/' . $fileIdx, [
                                        'headers' => [
                                            'Authorization' => 'Basic ' . base64_encode($userNameNuxeo.":".$mdpNuxeo),
                                            'X-Upload-Type' => 'chunked',
                                            'X-Upload-Chunk-Index' => $chunkIdx,
                                            'X-Upload-Chunk-Count' => $nbChunks,
                                            'X-Batch-No-Drop' => true,
                                            'X-File-Name' => $fichier->getClientOriginalName(),
                                            'X-File-Type' => $iteropFile->getMimeType(),
                                            'Content-Type' => 'application/octet-stream',
                                            'X-File-Size' => filesize(realpath($iteropFolderPath . $fichier->getClientOriginalName()))
                                        ],
                                        'body' => fopen(realpath($iteropFolderPath . $fichier->getClientOriginalName()), 'r')
                                    ]);
   }

At runtime I get HTTP/1.1 308

So how to fix it ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *