Skip to main content

Extract File Size from From Attachments


I am facing issue in Files Table. I have column name “File” ,I did the setup to get the size using formula, in column “File size” but that is not working now. Can you please help me with this issue?

Actually, It was working till yesterday , but today it stopped working and I cannot find the formula. Can you please help me out with the task, I jsut want formula to get File Size from From Attachments.

12 replies

ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • June 9, 2022

There isn’t a formula to get the file size from attachments, but you can get it through Airtable’s automations, which will reveal the size of attachments.

Alternatively, you can get the file size through any tool that has access to the Airtable API, such as scripting, datafetcher.com, Make’s automations and integrations, or MiniExtensions’ attachment size extension.

p.s. If your company has a budget for your project and you’d like to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld 


  • Author
  • New Participant
  • 2 replies
  • June 9, 2022
ScottWorld wrote:

There isn’t a formula to get the file size from attachments, but you can get it through Airtable’s automations, which will reveal the size of attachments.

Alternatively, you can get the file size through any tool that has access to the Airtable API, such as scripting, datafetcher.com, Make’s automations and integrations, or MiniExtensions’ attachment size extension.

p.s. If your company has a budget for your project and you’d like to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld 


Hey @ScottWorld Can yo help me with more information on Automation that will revel the size of Attachments.


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • June 9, 2022

You could trigger your automation with a checkbox field or a single-select field, and then update the record with the size of the attachment in a separate size field.

Check out this thread on how to instantly trigger a Make automation from Airtable.

p.s. If your company has a budget for your project and you’d like to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld 


Hannah_Wiginton
Forum|alt.badge.img+18

Our On2Air Actions app has a function that will calculate the sum of all file sizes in a field.


Alexey_Gusev
Forum|alt.badge.img+23

Hi,

may be useful for you, some time ago i did a script to count size of all attachments in all base per table

const inMb=(bytes)=>(bytes?`${Math.round(bytes/Math.pow(1024,2))} Mb`:'');const ts=[];

for(var table of base.tables) ts.push(await count(table))

if (sum(ts)) {output.table(ts.filter(n=>n).map(x=>(x?{size:inMb(x.size),name:x.tname}:{})));

output.markdown(`**Total: **${inMb(sum(ts)?.size)}`)}

function sum(arr){return (!arr||!arr.length||!(arr.some(n=>n)))? null:

{size:arr.filter(n=>n).map(x=>x.size).reduce((x,y)=>x+y),tname:table.name}};

async function count(table){

  let flds=table.fields.filter(fld=>fld.type.includes('Attach'));

  let query=await table.selectRecordsAsync({fields:flds});

return sum(flds.flatMap(fl=>query.records.map(x=>x.getCellValue(fl)).map(sum)));}

  • Author
  • New Participant
  • 2 replies
  • June 10, 2022
Alexey_Gusev wrote:

Hi,

may be useful for you, some time ago i did a script to count size of all attachments in all base per table

const inMb=(bytes)=>(bytes?`${Math.round(bytes/Math.pow(1024,2))} Mb`:'');const ts=[];

for(var table of base.tables) ts.push(await count(table))

if (sum(ts)) {output.table(ts.filter(n=>n).map(x=>(x?{size:inMb(x.size),name:x.tname}:{})));

output.markdown(`**Total: **${inMb(sum(ts)?.size)}`)}

function sum(arr){return (!arr||!arr.length||!(arr.some(n=>n)))? null:

{size:arr.filter(n=>n).map(x=>x.size).reduce((x,y)=>x+y),tname:table.name}};

async function count(table){

  let flds=table.fields.filter(fld=>fld.type.includes('Attach'));

  let query=await table.selectRecordsAsync({fields:flds});

return sum(flds.flatMap(fl=>query.records.map(x=>x.getCellValue(fl)).map(sum)));}

Hey, hanks for he reply, I just want to calculate the Size of one file at a time and Use to Script to calculate every new file added in my Airtable Row and File size into its Corresponding table.
Can you help me with that.


  • New Participant
  • 1 reply
  • June 19, 2022

I’m also looking for a solution to calculate a single file, this is really odd it doesn’t exist.


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • June 19, 2022
Eli_Mag wrote:

I’m also looking for a solution to calculate a single file, this is really odd it doesn’t exist.


The only way that you can calculate the size of a single file within an attachment file that contains multiple files in it would be to loop through the array of all the attachments in that field.

As of 2023, looping is now supported by Airtable’s Automations, so you can now do this with Airtable’s automations.

However, it’s usually recommended to use Make’s advanced automations to do these sorts of advanced automations.

In Make, you loop through arrays using its iterator tool.

I give a demonstration of working with attachment arrays on this Airtable podcast episode.

And here is how to instantly trigger a Make automation from Airtable.

p.s. If your company has a budget for your project and you’d like to hire an expert Airtable consultant to help you with any of this, please feel free to contact me through my website: Airtable consulting — ScottWorld 


Forum|alt.badge.img+6
  • Known Participant
  • 22 replies
  • March 25, 2024

Is there a better way meanwhile?

Or could you, @ScottWorld please elaborate how an Automation could be used to get the file size? I am quite familiar with automations in general, however, I don't get what you are referring to.


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • March 25, 2024

The file size is one of the values that Airtable gives you in its native automations and in its API. Where are you getting stuck? Please post screenshots or a video.


Forum|alt.badge.img+6
  • Known Participant
  • 22 replies
  • March 25, 2024
ScottWorld wrote:

The file size is one of the values that Airtable gives you in its native automations and in its API. Where are you getting stuck? Please post screenshots or a video.


Ahh, got it. The context menu when selecting a value to be updated. It works. Thanks!


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8759 replies
  • March 25, 2024

Fantastic! You’re welcome! 😀


Reply