Skip to main content
All CollectionsAutomationsPublic URLs for Airtable Attachments
How can I link to all the files in an attachment field?
How can I link to all the files in an attachment field?

My field contains multiple files. How do I choose which to load if there are multiple files present?

Updated over a week ago

This automation generates individual URLs for each file in the attachment field. You can modify the index in the URL to access a specific file within the field. The index begins at 1. Here is an example URL.

https://web.miniextensions.com/api/public-attachments/l9v2rOh9nqDPG1z8OVzi/rec1xGA04dDbrQjxb/1

You just need to change the number at the very end of the URL to change the index, which will in turn give you the 1st, 2nd, 3rd etc. attachment in the field.

How to include links to several attachments in the same field

If you need to have links to all attachments in a single field, and the number of attachments per record varies, you can use the following method involving an additional formula field (that you could hide afterwards). Here's how you can do this:

  1. Create a formula field in your Airtable base. Let's call it Number of files.

  2. Use the following formula for the new field, where Attachment is the name of your attachment field. This will count the number of attachments in your field, which we need to then display the correct number of links in your public URLs field:
    IF(Attachment=BLANK(), 0, LEN(Attachment)-LEN(SUBSTITUTE(Attachment,",",""))+1)

  3. Once you have this additional field set up, please verify that the number of files are reflected correctly. If they're not correct, try using a second additional formula field as described here.

  4. Now you just need to adjust your original public URLs formula field to show additional links depending on the number of attachments. You can do this like so:
    'https://web.miniextensions.com/api/public-attachments/l9v2rOh9nqDPG1z8OVzi/' & RECORD_ID() & '/1' & IF({Number of files}>=2, ' https://web.miniextensions.com/api/public-attachments/l9v2rOh9nqDPG1z8OVzi/' & RECORD_ID() & '/2') & IF({Number of files}>=3, ' https://web.miniextensions.com/api/public-attachments/l9v2rOh9nqDPG1z8OVzi/' & RECORD_ID() & '/3') etc...

The key differences for each entry are highlighted with bold text. Extend the formula as needed up to the maximum number of attachments you would expect.

What is the impact on existing URLs that do not include the index?

If the URL does not include the index number, it will function as before and display the first file in the attachment field. You can just add the new parameter in your existing URL if you want to change it to another file in the field.

Did this answer your question?