1. The first way
downloadTitle = md.headers('content-disposition').split(';')[1].split('=')[1]; downloadTitle = decodeURI(downloadTitle);
2. The second way
const disposition = res.headers["content-disposition"] const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; const matches = filenameRegex.exec(disposition); const filename = matches[1].replace(/['"]/g, '');