We've had a longstanding issue with media in the Recycle Bin and I feel like I must be missing something.
When a file is deleted from the Media section, it's moved into the Recycle Bin. However, if a customer browses directly to the file's URL then it still opens. How can I prevent this? We often "delete" old media files but it's easy for editors to forget to empty the Recycle Bin, and then customers end up looking at outdated information (usually when the media has been indexed directly by Google).
I can't figure out how to block customer access to media files that are in the Recycle Bin. How can I do this?
In an attempt to fix this, I'm trying to hook an event up to the Trashed event that'll rename the file to something like "blah.jpg-deleted" so that it'll 404 if anyone accesses it with an old link.
However, I can't figure out how to get the path to the file. MediaService.Trashed provides a MoveEventArgs<IMedia> called e and I've tried variations of:
foreach (var item in e.MoveInfoCollection)
{
var path = Server.MapPath(item.Entity.Path);
}
However, this doesn't work as Path contains the Umbraco path (eg. -1,-21,1234) and not the actual file path. How do I get the file path?
Block access to media in Recycle Bin
We've had a longstanding issue with media in the Recycle Bin and I feel like I must be missing something.
When a file is deleted from the Media section, it's moved into the Recycle Bin. However, if a customer browses directly to the file's URL then it still opens. How can I prevent this? We often "delete" old media files but it's easy for editors to forget to empty the Recycle Bin, and then customers end up looking at outdated information (usually when the media has been indexed directly by Google).
I can't figure out how to block customer access to media files that are in the Recycle Bin. How can I do this?
Thanks :)
In an attempt to fix this, I'm trying to hook an event up to the Trashed event that'll rename the file to something like "blah.jpg-deleted" so that it'll 404 if anyone accesses it with an old link.
However, I can't figure out how to get the path to the file. MediaService.Trashed provides a MoveEventArgs<IMedia> called e and I've tried variations of:
However, this doesn't work as Path contains the Umbraco path (eg. -1,-21,1234) and not the actual file path. How do I get the file path?
Can we just get rid of the recycle bin? Or have a config option that lets us bypass it? I don't understand why it's there in the first place.
Just write an event handler that extends MediaService.Trashed
is working on a reply...