why storing an image object in supabase is stored ...
# help
m
why storing an image object in supabase is stored as text? "{"size":5849107,"mimetype":"text/plain;charset=UTF-8","cacheControl":"max-age=3600"}" If I store it directly on the client it works and stores it as "image/png" but if I store it though my /api/file.js and then to Supabase it stores it as text, check out my code: //index.svelte
Copy code
async function handleFile(){
    const formData = new FormData();
    formData.append("file", file);
    let resp = await fetch( '/api/file', {
      method: 'POST',
      body: formData,
    })
    console.log(resp)
  }
//api/file.js
Copy code
import {supabase} from '/src/lib/supabaseClient'

export async function post(event) {
  const data = await event.request.formData();
  const fichero = data.get('file')

  const {data: imageData, error:imageError} = await supabase
  .storage
  .from('images')
  .upload("algomio/"+Date.now(),fichero,{
    cacheControl: '3600',
    upsert: false
  })
  if(imageData){
    console.log("imageData: ",imageData)
  }
  if(imageError){
    console.log("imageError:", imageError)
    
  }

  return {
    body: {algo:"algo"}
  }
}
n
Hello @malaleche! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
m
Fixed like this:
Copy code
const {data: imageData, error:imageError} = await supabase
  .storage
  .from('images')
  .upload("algomio/"+Date.now()+".png",file,{
    cacheControl: '3600',
    upsert: false,
    contentType: "image/png"
  })