Skip to content

Instantly share code, notes, and snippets.

@smsohan
Last active December 21, 2015 07:19
Show Gist options
  • Save smsohan/6270255 to your computer and use it in GitHub Desktop.
Save smsohan/6270255 to your computer and use it in GitHub Desktop.
LinkedResource using a Stream instead of a file path on disc
public class StreamResourceProvider : LinkedResourceProvider{
/// <summary>
/// Gets a linked resource given its Id and FilePath
/// </summary>
public override LinkedResource Get(string contentId, string filePath){
var stream = GetYourStream(contentId, filePath);
return new LinkedResource(stream);
}
private Stream GetYourStream(contentId, filePath){
//initialize the stream based on your custom logic
}
}
public class YourMailer : MailerBase{
public YourMailer(){
//Use the StreamResourceProvider for your mailer
this.LinkedResourceProvider = new StreamResourceProvider();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment