Skip to main content
Solved

How to add files along with other records

  • May 26, 2020
  • 1 reply
  • 2 views

I have a table that is suppossed to create records for file attachment and other details.

Juding from code below, How do I attach files along with other records in airtable.

Do I have to convert the file to base64 or just upload the files to a remote server and then add the file links in the record.
How does air table programmatically handle files attachments be it photos, pdf, videos etc. can someone help me out with the code below

Thanks

const files_tab = base.getTableByNameIfExists('myfiles_table');
const ok = files_tab.createRecordAsync({'title': 'file title','description': 'file details', 'myfile': 'my file attachment goes here'});

Best answer by Matthew_Thomas

You should be able to add any URL that points to a file in the value for ‘myfile’ (which assumes you have a Field with the same name). This custom block documentation describes the parameters for multiple attachment fields.

This would assume the file is located at an addressable URL (already uploaded somewhere on the internet). It doesn’t appear that custom blocks directly supports file input yet (the scripting block does with input.fileAsync. However, one of the custom block examples, JSON Import Block includes this functionality, much of which can be seen in the open source GitHub repo (this file in particular seems relevant to your problem).


If this answers your question, please consider marking it as “solution”. If not, I’m happy to work with you further. Thanks!

View original
Did this topic help you find an answer to your question?

1 reply

You should be able to add any URL that points to a file in the value for ‘myfile’ (which assumes you have a Field with the same name). This custom block documentation describes the parameters for multiple attachment fields.

This would assume the file is located at an addressable URL (already uploaded somewhere on the internet). It doesn’t appear that custom blocks directly supports file input yet (the scripting block does with input.fileAsync. However, one of the custom block examples, JSON Import Block includes this functionality, much of which can be seen in the open source GitHub repo (this file in particular seems relevant to your problem).


If this answers your question, please consider marking it as “solution”. If not, I’m happy to work with you further. Thanks!


Reply