Reputation:
In version 3 of Silverstripe, you could set Upload files to overwrite files in your config:
# replace files instead of versioning
Upload:
replaceFile: true
# show an overwrite warning
UploadField:
defaultConfig:
overwriteWarning: true
I'm hoping to achieve the same thing in SS4 but am unable to find the solution. From what I can glean from the documentation, I need to set AssetStore::CONFLICT_OVERWRITE
to true, but I'm not sure where to do this.
Any help would be much appreciated.
Upvotes: 1
Views: 167
Reputation: 4626
AssetStore::CONFLICT_OVERWRITE
is a constant, so you cannot overwrite it.
But in UploadField::__construct()
I see:
// When creating new files, rename on conflict
$this->getUpload()->setReplaceFile(false);
So theoretically you should be able to do something like:
$uploadField = UploadField::create(...);
$uploadField->getUpload()->setReplaceFile(true);
to overwrite the file.
Upvotes: 1