Skip to content

Instantly share code, notes, and snippets.

@justin-lyon
Created May 6, 2019 18:06
Show Gist options
  • Save justin-lyon/c42a90d6106fa7c9c2107470acd87dce to your computer and use it in GitHub Desktop.
Save justin-lyon/c42a90d6106fa7c9c2107470acd87dce to your computer and use it in GitHub Desktop.
public String getResourceContent(StaticResource resource, String fileName) {
String modStamp = String.valueOf(((DateTime)resource.SystemModStamp).getTime());
List<String> path = new List<String>();
path.add('/resource');
path.add(modStamp);
path.add(resource.Name);
path.add(fileName);
String url = String.join(path, '/');
// PageReference .getContent() is not Testable.
PageReference fileRef = new PageReference(url);
return fileRef.getContent().toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment