Save the date! Join us on October 16 for our Product Ops launch event. Register here.
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?
Aug 01, 2020 06:01 AM
Hi! I have sooo enjoyed this script for images. But I have a PDF automatic download link like this: https://www.teacherspayteachers.com/Preview/Noun-Sort-Cut-and-Paste-083291900-1381063936?fn=valentin...
That is NOT pulling the PDF correctly. Any ideas?
Aug 01, 2020 10:11 AM
One idea - that URL is not publicly accessible, a requirement of Airtable attachments.
Aug 03, 2020 07:04 PM
Ah, makes sense. Ok, thanks!
Aug 05, 2020 12:24 PM
How about this? I know it is in a viewer…https://www.teacherspayteachers.com/pdfjs/view.html?file=https%3A%2F%2Fpreview-2.teacherspayteachers...
Aug 05, 2020 02:30 PM
Viewers do note make it possible for a GET request to access the file. Viewers are for humans; Airtable’s attachment system is a machine.
Aug 06, 2020 05:44 AM
Ha, yeah, I know. I want the impossible :slightly_smiling_face:
Aug 06, 2020 06:14 AM
The viewer you shared is an HTML proxy for viewing what appears to be a PDF document. Someone needs to tell you how to look at the PDF without going through that proxy. Then, and only then, will Airtable be able to ingest the documents.
Aug 07, 2020 08:05 AM
So, i’ve been following along on this, trying to apply it to my own table.
Could you possibly post the entire script, start to finish, that you were able to execute fully? Then I might be able to more clearly see where my error is…!
Aug 07, 2020 06:21 PM
Hi - This script works great for one URL to attachment , but is it possible to make it work with several URLs? I have 7 columns of URL images (some records do not have all 7 filled), and tried to get it to do more than one column but have been unsuccessful. (My scripting levels are not great but I usually can get there in the end after a lot of trial and error, but I’ve come to a standstill on this attempt. )
Thanks
Sep 15, 2020 06:01 PM
@Stephen_Suen @Kasra, this is all working great for me except for one component: My image in the Attachment field doesn’t display as it should. See screenshot above. The link I am trying to load goes to a Google Drive image file. The permissions are set so anyone with the link can view.
How can I modify the code or the link so it correctly imports the Google Drive link as an attachment?
The link follows this pattern:
https://drive.google.com/file/d/file_id/view?usp=sharing
Here is the code:
let submissionsTable = base.getTable('Table 10');
let urlField = submissionsTable.getField('Attachment Source URL');
let attachmentField = submissionsTable.getField('Attachment');
let submissionsQuery = await submissionsTable.selectRecordsAsync();
let updates = [];
for (let record of submissionsQuery.records) {
let url = record.getCellValue(urlField);
let attachments = record.getCellValue(attachmentField);
// If this record already has an attachment, skip it.
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 submissionsTable.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}