storage icon indicating copy to clipboard operation
storage copied to clipboard

>100 KB File Upload Throws "TypeError: fetch failed"

Open VCasecnikovs opened this issue 9 months ago • 3 comments

Bug report

  • [x] I confirm this is a bug with Supabase, not with my own application.
  • [x] I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When trying to upload big file from server-side user action in Next.JS it throws an error described above.

In 10% if the image is less then 100KB all is done successfully.

Code to throw an error

 const { data, error } = await createServerActionClient({ cookies }, { supabaseKey: process.env.SUPABASE_SERVICE_ROLE_KEY, supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL })
            .storage
            .from('images')
            .upload(path, image);

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Mac OS
  2. Call function above from Next.JS server actions (I saw same problem on StackOverflow without Next.JS server actions)
  3. Error

Expected behavior

The image must be uploaded to the Storage

Screenshots

Screenshot 2023-09-17 at 20 53 42

System information

  • OS: MacOS
  • Version of supabase-js: 2.33.2
  • Version of Node.js: 20.5.1

Additional context

Error, which looked similar (NOT ON GITHUB): https://stackoverflow.com/questions/76424910/supabase-typeerror-fetch-failed

VCasecnikovs avatar Sep 17 '23 22:09 VCasecnikovs

I have temporary solved this problem for myself:

The problem happens, when I send File to Supabase Storage.

To solve the problem, I send Array Buffer:

let array_buffer = await image.arrayBuffer();

VCasecnikovs avatar Sep 17 '23 23:09 VCasecnikovs

I'm having this issue aswell. image

arthur-es avatar Nov 30 '23 12:11 arthur-es

I have to send array buffers as well.

simonhackler avatar Feb 22 '24 15:02 simonhackler

Closing this issue for now. By sending arrayBuffer seems the correct approach.

fenos avatar Mar 29 '24 09:03 fenos