supabase / supabase

The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
https://supabase.com
Apache License 2.0
73.55k stars 7.1k forks source link

Cannot display images on Supabase storage #29348

Closed manel00 closed 2 weeks ago

manel00 commented 1 month ago

Bug report

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

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

async function uploadImage(file) {
    console.log(file)
    const fileExt = file[0].filename.split('.').pop();
    const fileName = `${Date.now()}.${fileExt}`;
    const { error } = await supabase
      .storage
      .from('test') // Nombre del bucket
      // .upload(fileName, file[0], {
      .upload(fileName, file[0].buffer, {
          contentType: file[0].mimetype
        });

    if (error) {
      console.error('Error uploading image:', error);
      return null;
    }

    const { publicURL, error: urlError } = supabase
      .storage
      .from('test')
      .getPublicUrl(fileName);
    console.log(publicURL)
    if (urlError) {
      console.error('Error getting public URL:', urlError);
      return null;
    }

    return publicURL;
  }

Expected behavior

Upload the picture properly

Screenshots

image

System information

Additional context

Add any other context about the problem here.

Hallidayo commented 1 month ago

Hi @manel00 - Thank you for opening the issue! Just a couple of questions:

Hallidayo commented 2 weeks ago

Hi all, We’re going to close this one due to inactivity. Please feel free to reopen if you’re still having issues here or open a new issue.