简体   繁体   English

无法删除Drupal 8.5上载的XML文件

[英]Unable to delete uploaded XML file on Drupal 8.5

I have created a media type that accepts XML files and saves them to a custom publicly accessible location on the server. 我创建了一个接受XML文件的媒体类型,并将其保存到服务器上一个可自定义的公共访问位置。

Ideally I would like the file to be overwritten when the exact same file is uploaded. 理想情况下,我希望在上传完全相同的文件时将其覆盖。 This does not happen, instead it creates a new file and adds a number on the end. 这不会发生,而是创建一个新文件并在末尾添加一个数字。 I have "Create new Revision" turned off. 我已关闭“创建新修订”。

To get around this issue I thought I could just delete the file via the CMS. 为了解决这个问题,我想我可以通过CMS删除文件。 The uploaded file has status of "Permanent" and is used 0 places. 上传的文件的状态为“永久”,已使用0个位置。 I know the cron job cleans up files for you, but when I run the cron the file in question is still there. 我知道cron作业会为您清理文件,但是当我运行cron时,相关文件仍然存在。 I figure it's because the file is set to permanent, but I don't see a way to flip this to temporary. 我认为这是因为文件已设置为永久文件,但是我看不到将其翻转为临时文件的方法。

Any help is much appeciated. 非常感谢任何帮助。

There is a setting nested away in the file system settings, which lets you configure it to remove (or not removed) orphaned files. 文件系统设置中嵌套了一个设置,可让您对其进行配置以删除(或不删除)孤立的文件。 If drush isn't removing them despite having no usages recorded, I'd check this option isn't ticked. 如果在没有记录使用情况的情况下drush仍未删除它们,我将检查该选项是否被选中。

The temporary and permanent status are used for storing temporary files during the upload/save process, so I wouldn't tinker with those too much. 临时和永久状态用于在上载/保存过程中存储临时文件,因此我不会过多地修改这些文件。

If you fancy making the form yourself using the form API, then you can save the file programmatically using the FILE_EXISTS_REPLACE parameter. 如果您想使用表单API自己制作表单,则可以使用FILE_EXISTS_REPLACE参数以编程方式保存文件。

https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/function/file_save_data/8.5.x https://api.drupal.org/api/drupal/core%21modules%21file%21file.module/function/file_save_data/8.5.x

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM