JavaScript---Method to get the value of filename passed in the background when downloading files

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, '');


Guess you like

Origin blog.51cto.com/dd118/2551181