tus-php icon indicating copy to clipboard operation
tus-php copied to clipboard

Unable to upload files - PATCH GONE

Open Aiosa opened this issue 2 years ago • 1 comments

Hello, I am unable to set up the server properly so that it uploads files.

tus.min.js:1 PATCH <URL> 410 (Gone)

file_loader.js:283 Chunk error! Error: tus: unexpected response while uploading chunk, originated from request (method: PATCH, url: <URL>, response code: 410, response text: , request id: n/a)

I am using client as follows:

const upload = new tus.Upload(file, {
     endpoint: "server/tus/",
     retryDelays: [0, 3000, 5000, 10000, 20000],
     chunkSize: this.chunkUploadSizeLimit,
     metadata: {
           name: file.name,
           type: file.type,
           fileName: file.name,
           relativePath: relativePath,
    },
     onError: (e) => { ... },
     onProgress: (bytesUploaded, bytesTotal) => {
           let percentage = Math.round(bytesUploaded / bytesTotal * 100);
           self._onUploadProgress(bytesTotal, percentage);
    },
    onSuccess: () => { .... }
});

And the server:

require("../vendor/autoload.php");
require_once "../config.php";
$server   = new \TusPhp\Tus\Server('file');
$server->setUploadDir($tmp_dir);
$response = $server->serve();
$response->send();
exit(0);

The client lives two directories up relative to the tus server so that relative path to server/tus/ runs the index.php from above. The same directory also contains the access rules:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/?(.*)?$ index.php?$1 [QSA,L]
  • The uploading progress bar reaches 100% and then shows the error with PATCH 410 GONE
  • I tried curling OPTIONS (200) HEAD (404) POST (400) PATCH (410) DELETE (404) with a non-existing key (since I did not upload any file successfully yet)
  • The upload directory is writable, tus_php.server.cache was created
    • Not setting the directory gave me error about not being able to open files in ..vendor/ankitpokhrel/tus-php/uploads so I guess it is set up correctly
  • The rewrite rules should be OK, tested redirection to a 'print it to me' php script

Thank you for your help.

Aiosa avatar Nov 09 '22 12:11 Aiosa

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jan 09 '23 00:01 github-actions[bot]