Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tus: invalid or missing Location header, originated from request #694

Open
Kam205 opened this issue May 31, 2024 · 1 comment
Open

tus: invalid or missing Location header, originated from request #694

Kam205 opened this issue May 31, 2024 · 1 comment
Labels

Comments

@Kam205
Copy link

Kam205 commented May 31, 2024

Describe the bug
Whenever I try upload a file I am getting "tus: invalid or missing Location header, originated from request".

Failed because: tus: invalid or missing Location header, originated from request (method: POST, url: http://localhost:54321/storage/v1/object/filesupload/Gomathi Professional Development (1) (1).pdf, response code: 200, response text: {"Id":"88ea47f7-2522-4980-a259-f8072e4da259","Key":"filesupload/Gomathi Professional Development (1) (1).pdf"}, request id: n/a)

To Reproduce
const upload = new tus.Upload(fileStream, {
endpoint:${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/filesupload/${file.name},
retryDelays: [0, 3000, 5000, 10000, 20000],
headers: {
authorization: Bearer ${accessToken[1]},
'x-upsert': 'true', // optionally set upsert to true to overwrite existing files
"Content-Location" : ${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/filesupload/${file.name},
location: uploadURl,
},
uploadDataDuringCreation: true,
uploadSize: fileBuffer.length,
removeFingerprintOnSuccess: true, // Important if you want to allow re-uploading the same file https://github.com/tus/tus-js-client/blob/main/docs/api.md#removefingerprintonsuccess
metadata: {
bucketName: BUCKET_NAME,
objectName: file.name,
contentType: 'image/png',

    },
    chunkSize: 6 * 1024 * 1024, // NOTE: it must be set to 6MB (for now) do not change it
    onError: function (error) {
        console.log('Failed because: ' + error.message)
        reject(error)
    },
    onProgress: function (bytesUploaded, bytesTotal) {
        var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)
        console.log(bytesUploaded, bytesTotal, percentage + '%')
    },
    onSuccess: function () {
        console.log('Download %s from %s', upload.file, upload.url)
        resolve()
    },
})
 upload.start();
});
  1. Execute command '...'
  2. Start upload '...'
  3. See error

Please try to reproduce the problem when uploading to our public tus instance at https://tusd.tusdemo.net/files/, if applicable to your situation. This helps us to determine whether the problem may be caused by the server component.

Expected behavior
File should uploaded.

@Kam205 Kam205 added the bug label May 31, 2024
@Acconut
Copy link
Member

Acconut commented May 31, 2024

This is likely not a bug in tus-js-client but a configuration problem where the endpoint that you have defined is not a tus upload creation URL. Hence the response from the endpoint does not include the Location header as is expected from tus-js-client. You should double check the endpoint URL and have a look at Supabase's documentation. I haven't used their services and don't know their API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants