Image upload via API from Appgyver

Hi, I’m new to baserow, I’m not used to programming in java, but I need your help. I’m trying to use baserow as an application’s backend, but I can’t. Basically, the user should click on the button, choose a photo from his gallery and appgyver should send this file to a table or baserow

this is the flow i’m using

The script works in the online preview https://platform.preview.appgyver.com/, but on mobile, this script doesn’t work. Could someone help me please, I urgently need this to work. This is the script that worked in the preview appgyver on the computer:

let { url, authorization, file } = inputs

const formData = new FormData()

// transform blob url into a blob
// "blob:https://platform.preview.appgyver.com/cc59fe7a-0fa3-4c4c-9343-656c2be2e6a1"
let blobResp = await fetch(file.path)
let blob = await blobResp.blob()
formData.append('file', blob, file.name)

try {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': authorization,
    },
    body: formData,
  })

  if (!response.ok) {
    throw new Error('Unable to upload file to endpoint.')
  }

  const parsed = await response.json()

  console.log('response:', parsed)

  return [
    0,
    {
      url: parsed.url,
      name: parsed.name,
      is_image: parsed.is_image,
      image_width: parsed.image_width,
      image_height: parsed.image_height,
      uploaded_at: parsed.uploaded_at,
      thumbnails: parsed.thumbnails,
      size: parsed.size,
      mime_type: parsed.mime_type,

    },
  ]
} catch (error) {
  console.error(error)
  return [
    1,
    {
      error: {
        code: 'unknown',
        message: 'Unknown error occurred while trying to upload file.',
        rawError: error,
      },
    },
  ]
}

I saw another page that posted the script for beckendless and I tried to adapt. Unfortunately, this one didn’t work either for the preview on the computer or on the mobile.

let { url, authorization, file } = inputs

const formData = new FormData()

const imagem = {
uri: file.path,
name: file.name,
size: file.size,
type: 'image/jpg',
};

formData.append('image', imagem);
formData.append('update', "");

try {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Authorization': authorization,
    },
    body: formData,
  })

  if (!response.ok) {
    throw new Error('Unable to upload file to endpoint.')
  }

  const parsed = await response.json()

  console.log('response:', parsed)

  return [
    0,
    {
      url: parsed.url,
      name: parsed.name,
      is_image: parsed.is_image,
      image_width: parsed.image_width,
      image_height: parsed.image_height,
      uploaded_at: parsed.uploaded_at,
      thumbnails: parsed.thumbnails,
      size: parsed.size,
      mime_type: parsed.mime_type,

    },
  ]
} catch (error) {
  console.error(error)
  return [
    1,
    {
      error: {
        code: 'unknown',
        message: 'Unknown error occurred while trying to upload file.',
        rawError: error,
      },
    },
  ]
}

I merged your topics. Better not double post.

Do you have any information about what’s going wrong specifically on mobile? It seems a bit strange that it works on desktop, but it does not work on mobile. How does the request look like that you’re making to Baserow and what is the response? It might have something to do with the file size because the hosted version of Baserow is limited to 20MB.