Apr 01, 2020 06:17 PM
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?
Oct 15, 2020 02:44 AM
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.
Oct 15, 2020 06:46 AM
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?
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:
I like a good mystery.
Oct 23, 2020 01:05 AM
Hey,
Those who are looking for a native solution to do this, please see my topic here :
Florian
Nov 16, 2020 09:26 AM
Exactly what I needed! Thank you!
Jan 23, 2021 02:58 AM
If the field with url have multiple urls, how do I add them as multiple attachments?
Nov 23, 2021 07:15 AM
You must create an array of objects
[
{ 'url': downloadUrl, 'filename': fileName },
{ 'url': downloadUrl, 'filename': fileName },
]
Nov 23, 2021 08:14 AM
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.
Jan 18, 2022 09:38 PM
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?
May 02, 2022 02:40 AM
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);
}