I am an intermediate-level Airtable user, and using it since 2yrs. Now I have started learning PHP, and I want to integrate the Airtable API with it.
So, I want to build a simple webpage (in PHP), in which the -
user clicks the ‘Browse Image’ button, & picks an image from his phone’s storage.
After picking, the image would be compressed with some other compressing tool.
The compressed image would replace the previous image in the ‘Attachments’ column, specified row no. (Ex. flow : Replace the current image in the ‘Attachments’ column of row #4 with the new compressed image).
Is this possible to do? If yes, can you refer any Docs/Links which might help me?
Any help is appreciated :slightly_smiling_face:
The Airtable API can upload any images that are publicly addressable. The URL for the image being uploaded must Be openly accessible to Airtable.
You PHP app must host the image in a location where Airtable can access it when you add the image to the attachment field. Airtable does the actual upload behind the scenes when you update the attachment field URL.
The Airtable API documentation is all you need to update the attachment field with a new image source.
Indeed, but there’s a flaw in this expectation. Once you complete the post to hand over the URL for Airtable to do its “upload”, which is really the act of making a copy via URL, Airtable needs some time to make the copy. This can take a few seconds or minutes depending on the connection, the size of the file, and the relative business of Airtable itself.
You’ll need to create a sleep-gap in your process to ensure Airtable has had enough time to create the image copy and unfortunately, there’s no call-back to inform you of this. Furthermore, there’s no [obvious] way of testing the field to see if the upload is complete. Or is there? :winking_face:
The way I test to see if an attachment field has a copy of the image is to test for the existence of large or small thumbnail images in the attachment collection. If you request the attachment field and there are thumbnails, the process likely completed. This is almost certainly validation, but there are cases where Airtable is unable to make thumbnails for unknown reasons.
That said, there’s no way to solve your case 100%, but I may have gotten you to 99.5%, eh?