Skip to main content
added 11 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

This information is contained in the response header. A bit of parsing ifis required:

String fileName = 'default name';
Pattern p = Pattern.compile('.+filename="(.+?)".*');
String contentDisposition = res.getHeader('Content-Disposition');
if(contentDisposition != null) {
  Matcher m = p.matcher(contentDisposition);
  if(m.find()) {
    fileName = m.group(1);
  }
}

This information is contained in the response header. A bit of parsing if required:

String fileName = 'default name';
Pattern p = Pattern.compile('.+filename="(.+?)".*');
String contentDisposition = res.getHeader('Content-Disposition');
if(contentDisposition != null) {
  Matcher m = p.matcher(contentDisposition);
  if(m.find()) {
    fileName = m.group(1);
  }
}

This information is contained in the response header. A bit of parsing is required:

String fileName = 'default name';
Pattern p = Pattern.compile('.+filename="(.+?)".*');
String contentDisposition = res.getHeader('Content-Disposition');
if(contentDisposition != null) {
  Matcher m = p.matcher(contentDisposition);
  if(m.find()) {
    fileName = m.group(1);
  }
}
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

This information is contained in the response header. A bit of parsing if required:

String fileName = 'default name';
Pattern p = Pattern.compile('.+filename="(.+?)".*');
String contentDisposition = res.getHeader('Content-Disposition');
if(contentDisposition != null) {
  Matcher m = p.matcher(contentDisposition);
  if(m.find()) {
    fileName = m.group(1);
  }
}