How to creat a record while using input.fileAsync

My question as below:

I use this script:

Let attachment = await input.fileAsync('Pls upload the cargo packing list')

Then I want to create a new record with one field as MultipleAttachment.
I want this MultipleAttachment field having the attachment input above by input.fileAsync.

As per the API, the MultipleAttachment written format as below:

Array<{
url: string,
filename?: string,
}>

How could I achieve my goal? I don’t know how can I have the url of the uploaded file by fileAsync.

Thanks

Hi Xuewen!

The result of input.fileAsync will give you the actual File object, but doesn’t currently upload that file anywhere. The API for MultipleAttachments cells currently requires a URL, meaning the attachment must be hosted somewhere first. That means that you’ll need to upload the file to a hosting service (programmatically or manually) prior to writing it to the attachment field.

Improving this admittedly cumbersome process for uploading attachments via scripts is a great suggestion - thanks for sharing your desired workflow!

Cheers,
Billy

1 Like

Hi Billy

Many thanks for that.
Sorry i just came back to the forum.

So my understand is that, so far i could not use the scripting, input.fileAsync, to easily generate a record with the file directly from input.fileAsync.

So what I want Airtable to support my workflow is that, once I received in an inquiry, i can use the scripting to analyze the inquiry and establish the records on different tables automatically, which includes the supporting files attached to the inquiry, which should be from mail or some local area in the computer.

Do you have any idea that I can accomplish this goal just by scripting?

Thanks

So my understand is that, so far i could not use the scripting, input.fileAsync, to easily generate a record with the file directly from input.fileAsync.

You cannot use input.fileAsync to generate a record. But at @Billy_Littlefield said you can still upload a file to Airtable it just needs to be uploaded somewhereelse that provides file hosting first.

Here is a quick example of uploading a file to airtable:

let table = base.getTable("Inquries");

// As Billy pointed out the file needs to be already be uploaded somewhere and accessable via a URL in order to upload it. 
let newAttachmentUrl = 'https://www.rspcasa.org.au/wp-content/uploads/2018/10/Kitten-season-is-here.jpg';

// Include any other fields and their values here.
await table.createRecordAsync({
    "Iquriry Name": "Kittens?",
    "Attachments": [{ url: newAttachmentUrl }]
});