© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
5 replies
rzvdrl

TUS error: RLS policy

Error: tus: unexpected response while creating upload, originated from request (method: POST, url: ... , response code: 403, response text: new row violates row-level security policy, request id: n/a)
async function uploadFile(file: File) {
        let uuid: string = uuidv4();
        console.log(`${user?.id}/${uuid}.${file.name.split(".").pop()}`)
        return new Promise<void>((resolve, reject) => {
            var upload = new tus.Upload(file, {
                endpoint: process.env.NEXT_PUBLIC_UPLOAD_ENDPOINT,
                retryDelays: [0, 3000, 5000, 10000, 20000],
                headers: {
                    authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY}`,
                    // 'x-upsert': 'true', // optionally set upsert to true to overwrite existing files
                },
                uploadDataDuringCreation: true,
                removeFingerprintOnSuccess: false, 
                metadata: {
                    bucketName: "videos",
                    objectName: `${user?.id}/${uuid}.${file.name.split(".").pop()}`,
                    contentType: "video/mp4",
                    cacheControl: 3600,
                },
                chunkSize: 6 * 1024 * 1024, // NOTE: it must be set to 6MB (for now) do not change it
.......
        })
    }
async function uploadFile(file: File) {
        let uuid: string = uuidv4();
        console.log(`${user?.id}/${uuid}.${file.name.split(".").pop()}`)
        return new Promise<void>((resolve, reject) => {
            var upload = new tus.Upload(file, {
                endpoint: process.env.NEXT_PUBLIC_UPLOAD_ENDPOINT,
                retryDelays: [0, 3000, 5000, 10000, 20000],
                headers: {
                    authorization: `Bearer ${process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY}`,
                    // 'x-upsert': 'true', // optionally set upsert to true to overwrite existing files
                },
                uploadDataDuringCreation: true,
                removeFingerprintOnSuccess: false, 
                metadata: {
                    bucketName: "videos",
                    objectName: `${user?.id}/${uuid}.${file.name.split(".").pop()}`,
                    contentType: "video/mp4",
                    cacheControl: 3600,
                },
                chunkSize: 6 * 1024 * 1024, // NOTE: it must be set to 6MB (for now) do not change it
.......
        })
    }


This is my RLS: ((bucket_id = 'videos'::text) AND ((auth.uid())::text = (storage.foldername(name))[1]))
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

RLS Policy Syntax Error
SupabaseSSupabase / help-and-questions
3y ago
RLS Policy
SupabaseSSupabase / help-and-questions
4mo ago
Restrictive RLS policy
SupabaseSSupabase / help-and-questions
2mo ago
RLS policy help
SupabaseSSupabase / help-and-questions
3y ago