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

How to set creator, Signed URL and Allowed Origins on Cloudflare TUS Upload #684

Open
SheryarKhan6242 opened this issue Apr 30, 2024 · 5 comments
Labels

Comments

@SheryarKhan6242
Copy link

SheryarKhan6242 commented Apr 30, 2024

Question
How to set the the creator id and signed url and Allowed orgins. Also can Allowed origins be a wild card ?

Setup details

Code:

        upload = new tus.Upload(file, {
            // endpoint: 'https://master.tus.io/files/',
            endpoint: 'https://api.cloudflare.com/client/v4/accounts/XXXXXXXXXXXXXX/stream',
            headers: {
                'X-Auth-Email': 'XXXXXXXXXXXXXXXX',
                'X-Auth-Key': 'XXXXXXXXXXXXXXXXXXXXXXXX'
            },
            chunkSize: 5 * 1024 * 1024,
            retryDelays: [0, 1000, 3000, 5000],
            creator: '123',
            requireSignedURLs: true,
            metadata: {
                name: videoName,
                filetype: file.type,
            },
            onError: function(error) {
                console.log('Upload error', error);
            },
            onProgress: function(bytesUploaded, bytesTotal) {
                console.log(bytesUploaded)
                var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2);
                console.log('Upload progress', percentage + '%');
                progressBar.style.width = percentage + '%';
            },
            onSuccess: function() {
                console.log('Upload complete');
                uploadLabel.style.display = 'block';
               
            });`
@Acconut
Copy link
Member

Acconut commented Apr 30, 2024

How to set the the creator id and signed url and Allowed orgins. Also can Allowed origins be a wild card ?

I don't know what these are. Please elaborate more.

@SheryarKhan6242
Copy link
Author

How to set the the creator id and signed url and Allowed orgins. Also can Allowed origins be a wild card ?

I don't know what these are. Please elaborate more.

This is the code that does resumable uploads on cloudflare stream. The js client that I'm using is
https://github.com/tus/tus-js-client
But I cannot find any option how to send creator and Signed option to set it on cloudflare

@Acconut
Copy link
Member

Acconut commented Apr 30, 2024

What are "creator" and "Signed option"? I don't CloudFlare's API and thus cannot help you until you provide more details on what these terms mean and what you want to do with them. Maybe provide a link where this is explained.

@SheryarKhan6242
Copy link
Author

What are "creator" and "Signed option"? I don't CloudFlare's API and thus cannot help you until you provide more details on what these terms mean and what you want to do with them. Maybe provide a link where this is explained.

Apologies. Please refer to the following link for TUS(Large size file uploads) https://developers.cloudflare.com/stream/uploading-videos/upload-video-file/

You can also refer to curl documentation, but because I'm using tus js client, so the fields might differ.

https://developers.cloudflare.com/api/operations/stream-videos-upload-videos-via-direct-upload-ur-ls

I wanted to know how can I achieve this using my tus js client to pass the creator id and the other 2 params I mentioned.

@SheryarKhan6242 SheryarKhan6242 changed the title How to set creator, Signed URL and Allowed Origins How to set creator, Signed URL and Allowed Origins on Cloudflare TUS Upload Apr 30, 2024
@Acconut
Copy link
Member

Acconut commented Jun 1, 2024

Those links helped, thanks.

requiresignedurls and allowedorigins should be set via the metadata option in tus-js-client. For the creator property, set Upload-Creator in the headers option.

I hope this helps!

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