I have a custom ContentType that implements IFileEmbeddableContentType. When I upload images or PDFs into this editor, the files save correctly, but upon each subsequent edit, it's like the filenames keep growing and a new copy gets saved with a longer filename until the path gets so long and starts throwing exceptions. Here is my code:
Here are the URLs upon inserting an image saving, then re-saving with only making text edits. You can see the image path gets longer
<img style="max-height: 240px; max-width: 320px;" alt="" src="/resized-image/__size/640x480/__key/lexplessoncfs/105-00/105_5F00_51n9tpoIGwL._5F00_SL250_5F00_.jpg" /></p> <img style="max-height: 240px; max-width: 320px;" alt="" src="/resized-image/__size/640x480/__key/lexplessoncfs/105-00/105_5F00_105_5F00_51n9tpoIGwL._5F00_SL250_5F00_.jpg" /></p>
e.Lesson.Description = _embeddedFileController.SaveFilesInHtml(e.Lesson.Description, f =>
{
if (!hasPermission)
{
_embeddedFileController.InvalidFile(f, "You do not have permission to add files to a session.");
}
using (var stream = f.OpenReadStream())
{
var targetFile = targetFileStore.AddFile(e.Lesson.Id.ToString("N"), String.Format("{0}_{1}", e.Lesson.Id.ToString(), f.FileName), stream, true);
if (targetFile != null)
{
return targetFile;
}
else
{
_embeddedFileController.InvalidFile(f, "An error occurred while saving an embedded file to the session.");
}
}
return null;
});