2

I am creating a module to upload video to an in house media converter - as part of the module installation I create a new content type called "user video" which has a file field as part of it.

I need to set this file field so it saves to the private files directory, however I am unable to do so. I can create the content type and add the file field - but never manage to get the upload destination to be private.

Sometimes I am able to change this via the admin interface, but sometimes this option is greyed out.

I have included the code below and would be grateful for any assistance.

//Create the file upload for the video to be converted
  $field_name = 'uploaded_video';

  //  Create the field definition array.
  $field = array(
   'field_name' => $field_name,
  'type' => 'file',
  );


  $field = field_create_field( $field );

 //  Create the field instance definition array.
  $instance = array(
      'field_name' => $field[ 'field_name' ],
      'entity_type' => 'node',
      'bundle' => 'user_video',
      'description' => 'A field for uploading video and audio content.',
      'label' => 'Video to upload',
      'settings' => array(
          'file_extensions' => 'mp4 avi wmv qti mov',
          'uri_scheme' => 'private',
          ),
      'widget' => array(
          'type' => 'file',
      ),
  );


//  Create an instance of the field and bind it to the bundle.
field_create_instance($instance)
0

1 Answer 1

0

If your issue is that the radio buttons are greyed out when trying to select the 'private' folder.

I needed SQL access for this one; I emptied the SQL table that relates to the field that stores the images. In my case deleting all items was not enough and I need to manually remove all rows from the table and then put them back after the next stages. in my case table field_data_field_upload_private files .

2
  • Hi thanks - the real problem is that when the content type is created in the module.install file it is not setting the file field to private upload.
    – nmcilree
    Commented Dec 23, 2014 at 14:30
  • Have you tried setting the asset path to private folder in settings.php? something like this: $settings['file_private_path'] = '/private';
    – user107005
    Commented Feb 9, 2022 at 12:13

Your Answer

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

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