UploadMediaForm::submitForm has hard coded the public file scheme as the destination:
if (file_exists('public://' . $file['filename'])) {
$this->logger->notice($this->t('File @filename already exists - It has been replaced', ['@filename' => $file['filename']]));
drupal_set_message($this->t('File @filename already exists - It has been replaced', ['@filename' => $file['filename']]));
}
$file_entity = file_save_data($data, 'public://' . $file['filename'], FILE_EXISTS_REPLACE);
Drupal comes with a second uri scheme,
private://
and allows additional schemes/stream wrappers to be defined. The file destination is configured in the destination field, so let's use that.
Patch follows.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | honor_upload_dest_setting-2901027-7.patch | 4.16 KB | treuliaux |
| #7 | honor_upload_dest_setting-2901027-6.patch | 4.02 KB | fathershawn |
| #4 | honor_upload_dest_setting-2901027-4.patch | 3.18 KB | fathershawn |
| #2 | honor_upload_dest_setting-2901027-2.patch | 3.18 KB | fathershawn |
Comments
Comment #2
fathershawnComment #3
fathershawnComment #4
fathershawnUnintentional trailing comma removed.
Comment #5
fathershawnFurther testing shows we should also pull in the path configuration from the field settings.
Comment #6
treuliaux commentedI'm sorry to ask you this, but could you make a third version of your patch with the last version I pushed on dev please ?
Comment #7
fathershawnHere is an updated patch that makes use of the scheme and the upload directory settings.
And a re-roll against HEAD is always a fair ask, even if I wasn't adding an improvement!
Comment #8
treuliaux commentedThanks for the update !
I just had to make slight changes to keep phpcs from yelling at me.
I'll push this patch on dev tomorrow !
Comment #10
treuliaux commented