The user file name is invalid

Hello everyone, I’m entering this world of technology and I’m making a lot of mistakes, but learning a lot.
I’m making an App using budibase as the front and baserow as the back, I want to upload an image, but it’s giving the same error as this topic here.

I’ve searched a lot and haven’t been able to resolve it.

Topic link: Image upload via API in File-Field

I’m using the database token to make the API calls.

URL:

Body:
{
“uploadImage”: [
{
“name”: “https://baserow.conectarmais.com.br/media/user_files/NGokBkCiZY4qUMFZMOHLZwVETpljajgL_b82eff3e5f11437a57268cd8f7ecd63a4615ec5f41cf633efc11bd6ce76cb83d.png
}
]
}

Response:
{
“error”: “ERROR_REQUEST_BODY_VALIDATION”,
“detail”: {
“uploadImage”: [
{
“name”: [
{
“error”: “The user file name is invalid.”,
“code”: “invalid”
}
]
}
]
}
}

Hi,

Welcome to the community and the world of software development.

Uploading an image (or any kind of file) into a File field is always a 2-step process.

  1. You need to upload the image using upload_via_url endpoint from the API. This is a POST request where you need to pass the url of your image in the body of the request. This returns a JSON response in the following format:
{
  "size": 2147483647,
  "mime_type": "string",
  "is_image": true,
  "image_width": 32767,
  "image_height": 32767,
  "uploaded_at": "2019-08-24T14:15:22Z",
  "url": "http://example.com",
  "thumbnails": {
    "property1": null,
    "property2": null
  },
  "name": "string",
  "original_name": "string"
}
  1. You pass this entire response in the second request instead of just the name property. So the body of your second request looks like this:
"uploadImage": [{
  "size": 2147483647,
  "mime_type": "string",
  "is_image": true,
  "image_width": 32767,
  "image_height": 32767,
  "uploaded_at": "2019-08-24T14:15:22Z",
  "url": "http://example.com",
  "thumbnails": {
    "property1": null,
    "property2": null
  },
  "name": "string",
  "original_name": "string"
}]