Posted by funkytraffic on October 8, 2012 at 10:19am
After upgrading from drupal 6 to 7 I want to turn a public file field into a private. Since it contains data the system does not allow this.
If I go to field settings it says: "There is data for this field in the database. The field settings can no longer be changed."
Is there a way to do this?
Comments
I think that this is a
I think that this is a legitimate question.
With an image field which already had numerous entries (data uploaded through it) I was able to change from public to private...
One can also understand if the files themselves don't move and some database search-and-replace is needed for previous uploads, but it would be nice if there was a workaround for making public filefields private.
Subscribe! Have an urgent
Subscribe!
Have an urgent need to convert public file field to private. Is there any solution?
yeah wondering the same,
yeah wondering the same, "private / public" option is disabled for the field .. how to move from one to another?
ok, nevermind, figured it
ok, nevermind, figured it out.
just in case someone is looking to do this, here are the steps:
1. backup your site and db
2. copy the table for your field to make a backup (in my case i copied: field_data_field_attachments to field_data_field_attachments_bk)
3. empty table field_data_field_attachments
4. go to drupal and the option to change the file system should be available, so change it
5. copy all data from field_data_field_attachments_bk back to field_data_field_attachments
6. go to drupal, select your content type, select your file field, in file path settings select retroactive update
7. click save and it will move all your files to the right place in file system and update your db to the new path
done.
I belive apart from the
I belive apart from the respective data table we need to also take a backup for the revision table in the above mention case field_revision_field_attachments
Need Drupal help?
Reach Me
Drupal Developer , Themer.
Required module
Excellent advice. Make sure you have http://drupal.org/project/filefield_paths installed.
Same issue but different
In Drupal 6 I was too inpatient to wait for the Drupal 7's feature of both public and private. I used the .htaccess to rewrite queries to system/files. This way I could determine which folders need to be private.
But how do you migrate that to Drupal 7? It took me the following steps:
drush vset file_default_scheme "private"drush sqlq "UPDATE variable f, variable t SET t.value=f.value WHERE f.name='file_public_path' AND t.name='file_private_path' "drush sqlq "UPDATE file_managed SET uri=REPLACE(uri,'public://','private://') where uri LIKE 'public://%'/admin/structure/types/manage/<your-content-type>/fields/<your-attachment-field>/field-settings</your-attachment-field></your-content-type>SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 Options None Options +FollowSymLinks <ifmodule mod_rewrite.c=""> RewriteEngine On RewriteBase / RewriteRule ^(.*)$ index.php?q=system/files/$1 [L] </ifmodule><ifmodule mod_rewrite.c=""> RewriteEngine off </ifmodule>