php - 在 Silverstripe 4 中将 Uploadfield 设置为覆盖
问题描述
在 Silverstripe 版本 3 中,您可以设置上传文件以覆盖配置中的文件:
# replace files instead of versioning
Upload:
replaceFile: true
# show an overwrite warning
UploadField:
defaultConfig:
overwriteWarning: true
我希望在 SS4 中实现相同的目标,但无法找到解决方案。根据我从文档中收集到的信息,我需要设置AssetStore::CONFLICT_OVERWRITE
为 true,但我不确定在哪里执行此操作。
任何帮助将非常感激。
解决方案
AssetStore::CONFLICT_OVERWRITE
是一个常数,所以你不能覆盖它。
但在UploadField::__construct()
我看到:
// When creating new files, rename on conflict
$this->getUpload()->setReplaceFile(false);
所以理论上你应该能够做类似的事情:
$uploadField = UploadField::create(...);
$uploadField->getUpload()->setReplaceFile(true);
覆盖文件。
推荐阅读
- python - Django 告诉我模板不存在
- javascript - 等待它解析promise,然后插入MySQL
- google-app-engine - gcloud - 无法配置我的 VPC 连接器以使用我的 Redis 实例
- unity3d - 如何使动画中的最后一个精灵播放超过 1 帧?
- debugging - 将 VS Code 调试器用于无服务器 lambda flask 应用程序
- python - 像属性一样访问字典“值”?
- swift - 如何让继承作用于闭包内的参数?
- sql - 计算订阅者的调用频率 SQL Netezza
- mysql - mysql db的分片配置
- python - Python SpeechRecognition 逐字逐句?连续输出?