Help

Re: URL to Attachment

8743 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Aaron_Phoenix
5 - Automation Enthusiast
5 - Automation Enthusiast

I have registration forms that collect a digital signature. It imports into airtable as a url, like this: (https://s3.amazonaws.com/files.formstack.com/uploads/3669579/85172110/582992994/signature_85172110.p...)

Can someone help me with a script that would convert this to an image attachment?

48 Replies 48

This may be a silly question Bill, but are you using the same batch of documents (i.e. PDFs you indicated) in all cases?

The only times I’ve seen this mystery photo popup for a moment and go away is when in fact the URL to the image no longer works, for example in the case of trying to pull an Instagram photo that has some kind of url timestamp embedded in it. When I then manually go to the URL it always produces an error. Also, certain file types seem to fail on me, like video URLs from Instagram and probably for good reason lol.

I have used Automations as well as Zapier zaps. I believe when you say API this would include a zap that relies on the Airtable API to work.

I am very happy to hear that there’s no technical rate or bandwidth limit from your experiments – and how cool that you were able to do some analytics logging too – but I am definitely curious about whether these same URLs that fail can be accessed via the regular web at the same time as they are failing in Airtable.

That’s good to hear. When did you start to examine these issues closely? My attention to this issue began in Nov 2019 and by Dec 19, 2019 we noticed a steep regression (i.e., many more failures). This issue was pervasive for about two months and on or about 20-Jan-2020 the error volume subsided to a much more intermittent experience. I believe the issue continues to plague API-based solutions but only from time-to-time; I have not performed any tests recently, although just checking on one client’s activity, the a small number of failures have occurred in the past 12 hours.

No. These are/were processes that generate new PDFs all day long.

This is correct. Zapier certainly uses “an” API to process its recipes.

To be clear, if there are bandwidth quotas, we’re not creating a condition where we have experienced them. :winking_face:

It’s a vital question in the quest to understand this issue and this was a key test as we researched it. In 100% of the cases, the URLs that failed were tested with a browser that was certified without a security context. This is a crucial aspect of our testing protocol but it wasn’t developed to isolate the cause of this problem. We test security protocols for video analytics and AI apps for transit surveillance systems and we have to keep clean machines with browsers that are void of any cookies or historical login knowledge. This was the environment we used to be certain that the URLs to these failing documents (a) existed, (b) contained content, and © were accessible without any security context.

It’s also important to note that our tests also developed metrics that showed in subsequent automation processes involving the same failed URLs, attachment success was likely on 27 of 100 retries of previously failed attachment attempts.

What does this data suggest?

  1. The issue is intermittent.
  2. Failures are not likely related to specific URLs.
  3. Failures are not likely related to the way the API is being used (relatively good success rate).
  4. The code executed using Airtable’s manual feature is not likely built on the API offered to the public.

If these observations are true, we can probably conclude there’s a high probability that the issue is in the API itself or the environment with which the API is being used.

We don’t use Zapier so I really can’t comment if that environment manages to avoid this issue. But there are two data points concerning this that should be considered:

  1. Zapier and others like Integromat supported Airtable long before the public API was released. This suggests these vendors probably don’t use the same gateway to access or update Airtable that the rest of us are required to use.
  2. There’s no evidence (that I’m aware of) where Zapier recipes have exhibited this attachment failure, although I don’t even know if Zapier and Integromat can perform attachments. I have a hunch they can and they are designed with different APIs separate and apart from public API.

I like a good mystery.

Florian_Verdon2
7 - App Architect
7 - App Architect

Hey,

Those who are looking for a native solution to do this, please see my topic here :

Florian

Exactly what I needed! Thank you!

If the field with url have multiple urls, how do I add them as multiple attachments?

You must create an array of objects

[
 { 'url': downloadUrl, 'filename': fileName },
 { 'url': downloadUrl, 'filename': fileName },
]

This can be done the no-code way as well with the Convert URL to Attachments function in On2Air Actions.

With Actions, you also get an additional 60+ features that integrate with Airtable.

Features like creating Google Docs automatically with Airtable data, bulk create, edit, or delete multiple records, set default field values, copy fields, perform financial calculations, sync Google Sheets, and more.

______________________________________
Hannah - On2Air.com - Automated Backups for Airtable

I am trying to run this but when I click run, nothing is happening in airtable. The script window is simply flashing blank. I also noticed if I pass the url into an attachment manually, it says unable to obtain metadata. Could it be an error with this site alone?

https://images1.apartments.com/i2/FoQUKOvUaZ9kFFrVZJYHKZPtIKt0_VRSpGprD4GGx9Q/117/deco-apartments-de...

geeno_spazzeeno
4 - Data Explorer
4 - Data Explorer

Here is the code that ended up working for me. Based on @Stephen_Suen and @Marty_McCoy’s version, adapted for a URL column which may have empty values:

let myTable = base.getTable('Table 1');
let urlField = myTable.getField('URL field name');
let attachmentField = myTable.getField('Attachment field name');

let submissionsQuery = await myTable.selectRecordsAsync();
let updates = [];

for (let record of submissionsQuery.records) {
    let url = record.getCellValue(urlField);
  
    // If the URL field is empty, skip this record.
    if (url === null) continue;
    
    // If this record already has an attachment, skip it.
    let attachments = record.getCellValue(attachmentField);
    if (attachments !== null) continue;
    

    // Otherwise, attach the image at the URL.
    updates.push({
        id: record.id,
        fields: {
            [attachmentField.id]: [{url: url}]
        }
    });
}

// Update records in batches of 50.
while (updates.length > 0) {
    await myTable.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}