I need help with downloading files that use the Content-Disposition header while using a headless browser. I am making requests and receiving responses that include the header for file attachments. However, I’m unsure about the proper way to save these files to my computer.
Here’s how my response object appears:
Response {
"contentType": "text/plain",
"headers": [
{
"name": "Cache-Control",
"value": "private"
},
{
"name": "Content-Length",
"value": "256"
},
{
"name": "Content-Type",
"value": "text/plain"
},
{
"name": "Server",
"value": "Microsoft-IIS/7.0"
},
{
"name": "Content-Disposition",
"value": "attachment; filename=\"ContactList_08-25-14.csv\""
},
{
"name": "Date",
"value": "Mon, 25 Aug 2014 12:19:25 GMT"
}
],
"id": 104,
"status": 200,
"statusText": "OK",
"url": "http://xxxxxxxxxx.com/xxxxxxxx/ExportSubscribers.aspx"
}
What are the steps to retrieve the filename from the Content-Disposition header and successfully download the file content? I’ve attempted various methods but haven’t found anything that works.