I have a pdf that I have created in a user control, (using PDF Sharp). I'm attempting to now save this pdf within the media section. I can get the pdf into a filestream, just not sure how I now save it into the umbracoFile property.
I have something like this at the moment:
// get the parent id for the container folder
var parentId = GetParentFolder();
// create a new media file for the pdf
var mediaType = MediaType.GetByAlias("File");
var mediaFile = Media.MakeNew("My new file", mediaType, new User(0), parentId);
saving a file to media section
Hi,
I have a pdf that I have created in a user control, (using PDF Sharp). I'm attempting to now save this pdf within the media section. I can get the pdf into a filestream, just not sure how I now save it into the umbracoFile property.
I have something like this at the moment:
// get the parent id for the container folder
var parentId = GetParentFolder();
// create a new media file for the pdf
var mediaType = MediaType.GetByAlias("File");
var mediaFile = Media.MakeNew("My new file", mediaType, new User(0), parentId);
// set the PdfDoc as the umbracoFile
// save the image into a mem stream location
var fileStream = new MemoryStream();
PdfDoc.Save(fileStream, false);
mediaFile.getProperty("umbracoFile").Value = fileStream;
fileStream.Close();
mediaFile.Save();
Any pointers would be greatly appreciated.
is working on a reply...