您是否尝试过创建ApplicationEventHandler并挂钩到此处列出的某个媒体事件:https://our.umbraco.com/Documentation/Reference/Events/MediaService-Events然后您可以比较用户尝试上传的文件与媒体缓存中已有的文件。
EG
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
}
}
}