2

I have been using public file system has the upload destination for file field. I want to change public file system into private file system. I cannot change it it showing below error.

There is data for this field in the database. The field settings can no longer be changed.

I cannot select the upload destination. How to change the file system for file field in drupal 8

1 Answer 1

6

I have no idea why the UI prevents from doing that. It's not actually anything in the storage, it's just the default for new files.

What you need to do is edit the config file directly, which is named field.field.$entity_type_id.$bundle.$field_name, for example field.field.node.article.field_image.

You can do that using drush cedit, or single export and then import it again from the UI, or do a full config export and import it again after changing that file.

3
  • Disclaimer: Note that this is not possible for everything, some changes are not allowed for a reason. Changing the size of a textfield for example can't be done as Drupal has no mechanism to update the table in the database if you have data.
    – Berdir
    Oct 12, 2016 at 18:25
  • 2
    Still works fine. But seems this now needs to be done inside field.storage.node.field_file.yml. uri_scheme: public must be replaced by uri_scheme: private, then config import, and it starts to work for all from now on added files, not for existing files.
    – leymannx
    Jul 9, 2018 at 20:22
  • 1
    I'm using now drush config-set field.storage.node.field_file settings.uri_scheme private -y. Found in this gist gist.github.com/jleehr/7ac2a5de785881dfce99f7034547f07b Nov 8, 2022 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.