Help

Formula for files size in attachment filed

10697 18
cancel
Showing results for 
Search instead for 
Did you mean: 
Forms_PTA
4 - Data Explorer
4 - Data Explorer

I am having users attach photos and I would like a way to show the size of a file so that we can have an indication of the size of the file attached. Doesn’t anyone have a solution for this?

Thanks in advance for your help.

18 Replies 18
alex
5 - Automation Enthusiast
5 - Automation Enthusiast

I’m looking into this as well. You can enable “grouping” and then it’ll have an indicator for that specific group of total file size:
image

I’m trying to then take that total file size and roll it up into a connected table so that it shows up as just a line item. Does anyone know if this is possible? Just as you can pull in “Count”, can you pull in “Total File Size” for attached records using Rollup?

I need the “Total Attachment Size” column to just give the total attachment size for the images column.
image

Totally happy to calculate this in the original table for the line item if that’s what has to happen:
image

Can’t seem to figure it out though. Wish I could just take that “18MB” total field and have it passed through as a field in the other base.

@openside you’re a master, any ideas?

Thanks everyone!

Any luck on this? I’m trying to do the same so I can flag any images that are too large.

@Brent_del_Rosario unfortunately not :frowning:

What we ended up doing was using Integromat to shrink the sizes of the images uploaded to like 1/4th the size just in-case at the time of generating the email that we are appending the attachments in Airtable to.

Not ideal, but it has solved the issue for now. Still wish this was a data-point that we could roll-up and have triggered views and such based on it.

Check out this extension:

This is updated version of the post (I missed some pictures in my earlier post):

Has anybody found a solution? Can’t believe there is nobody. Searched google and it doesn’t look like anybody has ever searched or asked same question. Even Integromat community doesn’t have an answer.
The Miniextenion can do that but I can’t justify spending 40 USD for 1 extension if paying 10 dollar for Airtable.

I’ll contact Integromat support, see what they say. It’s easy to get one attachment size with Integromat. You just need the Airtable Watch module and the Airtable Updater module and that will write the attachment file size into a field of your choice.

The problem is, I couldn’t find how to get total size of all attachments in the particular field. Array functions were of no help, it can get files but I wasn’t able to get the sizes to add up. Even tried adding variables etc to no avail.

size
size1
size2
size3
size4
size5

Here's a related thread for a suggested feature (product idea) about attachment file sizes:
https://community.airtable.com/t5/product-ideas/attachment-file-size-type-limits/idi-p/55500

Alvaro_Hernande
6 - Interface Innovator
6 - Interface Innovator

I write this script into an automation. When an attachment field is updated, it gets the sum of all the files in the attachment field and put it into a number type field.

const table = base.getTable('Your Table Name');
const fieldWithAttachments = 'Attachments Field Name';
const fieldToStoreSizes = 'Sizes Field Name';

// Retrieve the specific record based on the provided recordId
const recordId = input.config().recordId;
const record = await table.selectRecordsAsync({ recordIds: [recordId] });
const selectedRecord = record.records[0];

const attachments = selectedRecord.getCellValue(fieldWithAttachments);

if (attachments) {
  // Iterate over each attachment in the field
  const sizes = attachments.map((attachment) => attachment.size || 0);
  const sum = sizes.reduce((acc, curr) => acc + curr, 0);

  // Update the sizes field with the calculated sum
  await table.updateRecordAsync(selectedRecord, {
    [fieldToStoreSizes]: sum,
  });
}

Remember to write your correct base name and fields in the three first lines

It works form me. Hope this solve the question.

😉

I tried this and I am getting this error? Any advice? 

Raquel4725_0-1693955800442.png

 

Alvaro_Hernande
6 - Interface Innovator
6 - Interface Innovator

Have you define in your automation input variables??

 

Alvaro_Hernande_0-1693979973626.png

That type of error seems to me that the script is not getting any value because input.config() not defined. But maybe if you give us more info we can understand better the issue.

 

😉