Image upload via API in File-Field

Hi community,

id like to upload images to my database via API. Unfortunately, I always get an error as soon as I want to upload a new image that is not yet in my database.

Error message
The user file name is invalid

My code

$data = ‘{
“image”:[{
}, “url”: “https://www.digital-sales.de/wp-content/uploads/2014/05/Tu-es-einfach-Just-do-it1.jpg”,
“name”: “Do-it-simply-Just-do-it1.jpg”
}]
}’;

Field type
File

What am I doing wrong?
Thanks in advance

Hi Sebastian, welcome to the Baserow community. Judging from the example code that you have provided, I think you’re trying to upload an image directly when updating/creating a row? This is unfortunately not possible. You must first upload your file, to the user files and after that it can be used in row. You might want to take a look at the documentation of these endpoints https://api.baserow.io/api/redoc/#operation/upload_file and https://api.baserow.io/api/redoc/#operation/upload_via_url. They describe how you can upload from disk or from a URL.

The name that’s in the response of user file endpoints, is that name that you can use when you want to update the file field value of a row. A small downside is that you can only upload files via the JWT authentication at this point. That means you can’t use token that you generated via the web-frontend for this. This is going to be changed in the future.

1 Like

Hi Bram,

thank you very much for the helpful answer. You already got it right, I wanted to upload the image directly (that would also make the process a bit less complicated from my point of view). Anyway, got it running through your helpful links.

I do have one question though: is there a way to view all the files already uploaded in one place?

Thanks a lot and greetings

Glad to hear that it worked for you. It’s unfortunately not possible to view all the files that you have uploaded.

Hi @bram any news about using the api token generated from the web-frontend?
also is there a way I can upload multiple files at once?

@mahmouds12 We expect to release this functionality in 1.12 (upcoming release). You can track the progress here: Add user file upload docs to the generated API docs (#255) · Issues · Bram Wiepjes / baserow · GitLab.

1 Like

It’s not possible to upload multiple files via one single API request. You can upload multiple by creating multiple simultaneous API requests though.

1 Like

Hey @bram - just started playing around with the product, it’s fantastic.

I have a bunch of S3 URLs in a URL field. I tried duplicating and converting the field type to File, but it doesn’t automatically upload the URLs, which is fine (although this functionality would be awesome).

Is the best way to automate uploads via URL to upload these URLs via API calls, or is there another method you suggest? Thanks!

Hi @allene-copilot, I would recommend uploading them manually via the API and update the related row for now. We already have an issue on the backlog related to the described functionality. You can track the progress here: Convert image URLs into image files (#1216) · Issues · Bram Wiepjes / baserow · GitLab.

1 Like