I use the following code for uploading videos from my React Native app to Supabase storage:
const fileExt: string = videoUri.split('.').pop() ?? 'mov'
const filePath = `users/${session?.user?.id ?? 'unknown'}/${formatFileDateTime()}.${fileExt}`
const formData = new FormData()
formData.append('files', {
uri: videoUri,
name: filePath,
type: `video/${fileExt}`
})
console.log('updatePostWithVideo 1', { postId, videoUri, filePath })
const { error: uploadError } = await supabase.storage.from(STORAGE_BUCKET_VIDEOS).upload(filePath, formData, { cacheControl: '3600' })
if (uploadError != null) throw uploadError
console.log('updatePostWithVideo 2')
const { publicURL, error: urlError } = supabase.storage.from(STORAGE_BUCKET_VIDEOS).getPublicUrl(filePath)
if (urlError != null) throw urlError
console.log('updatePostWithVideo 3', { publicURL, filePath })
I never reach 'updatePostWithVideo 2', instead I get an error (timeout?) before that.
On https://app.supabase.com/ in the Storage file browser, after a while it says “File is corrupted, please delete and reupload this file again”
What am I doing wrong?
UPDATE: I’m on the Pro plan so the 50 MB limit does not apply.