First post here after doing a bit of googling to no avail…
I’m looking for an example of how to upload a zip archive to an attachment field. In the documentation there is mention of attachment objects but no mention of how to create one pro-grammatically. Any sample code or general guidance would be helpful regardless of language although Python would be greatly appreciated!
Welcome to the Airtable community!
In order to upload an attachment with the API, the attachment must first exist at a publicly accessible url. So, you must first upload your attachment to some other web service, get the url for it, then use that url with your create/update request.
Are you saying that AirTae will transfer the file from the public endpoint to its own storage? I’m not looking to create an external link via the attachment object. What I am looking for is a way to upload a file to AirTable in much the same way AirTable’s drag and drop web UI does it when one attaches a file uploading from a local device. When one uploads a file in this way an attachment object is created which has a url that points to https://dl.airtable.… Is this a web UI feature only? I do not want these files to be public and I’d prefer not to have to click around in the UI to accomplish this task.
Yes, Airtable will retrieve the file from the public url and make its own copy to store as an attachment. Once the attachment is uploaded, you can delete the public version. The attachment create with the API will also work exactly as any other attachment created in the UI.
@UME_System Since you mentioned concerns about your attachments being public, one thing you should note is this:
Once your attachments are in Airtable, and once a user of your Airtable base has access to the https://dl.airtable URL of an attachment, that attachment will always be publicly visible via that URL to anyone who gets hold of that URL… even if you delete the attachment from Airtable.
Even if you delete the attachment from Airtable, the attachment lives on publicly at that URL for an indefinite amount of time (presumably 1 year, if you are on the Pro plan).
But that https://dl.airtable URL does not sit behind any type of security. If a user distributes that URL to the general public, or even if the user themselves goes back to that URL a year later, the attachment will still be visible.
I would like to bump this as well. Pretty ridiculous to still require a public link to upload private documents; especially given the fact that Airtable links are now expiring for security reasons and the fact that this ask has been out for three years now. Honestly; I'm very surprised there isn't a differentiation between private attachments and public attachments. They really should be separate field types in the table creation process. Private documents should only be accessible from logged-in users with correct permissions or via API with a properly configured PAT. This two hour timeout thing is a cheap substitute for real security.
Hi @kuovonne ! How do I tell airtable to retrieve the file from the public URL to make its own copy to store as an attachment? I have the URL, just not sure how to get airtable to automatically extract the document and upload it to a document field.
@Sarah_MacGregor Is your public URL in an Airtable field? You can use an automation to upload the attachment. Use an "update record" action where you copy the url to the attachment. Or you can use scripting.