I would like to download attachments via a link keeping the original file name. I managed so far to upload a document with the correct file name but the issue is that when downloading in another page it becomes a new generic names for all files
Do any of you know a solution to this? This is currently being integrated with Softr.
One solution to this is to use a service like Cloudinary to host the files, and then use their API to generate a download link with the original file name. This way, when the link is clicked, the file will be downloaded with the original file name.
Another solution is to use a server-side script that retrieves the file from Airtable and sends it back to the client with the original file name as the attachment name. This can be implemented using a language like PHP, Python, etc.
I am familiar with PHP, so I have included a sample. Please check:
//Airtable API Key and Base ID
$api_key = "YOUR_API_KEY";
$base_id = "YOUR_BASE_ID";
$attachment_id = "YOUR_ATTACHMENT_ID";
//Get the attachment from Airtable using the API
$curl = curl_init();
CURLOPT_URL => "https://api.airtable.com/v0/$base_id/attachments/$attachment_id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer $api_key"
$response = curl_exec($curl);
//Decode the JSON response
$data = json_decode($response, true);
//Get the original file name
$file_name = $data["filename"];
//Get the URL of the attachment
$url = $data["url"];
//Download the attachment
header("Content-Disposition: attachment; filename='$file_name'");
You can also use the Softr integration to keep the original file name when downloading attachments via a link. They have a built-in feature for this; you may need to check their support documentation for more information on how to use it.
It's important to note that the solution will depend on the specifics of your integration with Softr and the technology you are using.