答案 0 :(得分:0)
您是否尝试过创建ApplicationEventHandler并挂接到此处列出的媒体事件之一:https://our.umbraco.com/Documentation/Reference/Events/MediaService-Events 然后,您可以将用户尝试上传的文件与媒体缓存中已存在的文件进行比较。
例如
public class MediaSaving : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase
umbracoApplication, ApplicationContext applicationContext)
{
MediaService.Saving += MediaServiceSaving;
}
void MediaServiceSaving(IMediaService sender, SaveEventArgs<IMedia> evt)
{
foreach (var mediaItem in evt.SavedEntities)
{
//Check if a new upload and correct type etc
//Compare file paths and overwrite if appropriate
}
}
}