![Page 1: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/1.jpg)
FLEXIBLE FILE PATHS FROM THE START
Prevent Drupal Headaches
Wednesday, January 15, 14
![Page 2: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/2.jpg)
training.acquia.com/events
Wednesday, January 15, 14
![Page 3: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/3.jpg)
Who is this for?• New to Drupal?
• Starting a new Drupal site!
• Inherited a new Drupal site and want to know more about configuration
Wednesday, January 15, 14
![Page 4: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/4.jpg)
In this demo• How file path patterns
affect maintenance and migrations
• File upload management
• Future friendly path patterns
Wednesday, January 15, 14
![Page 5: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/5.jpg)
Source of the pain?• Drupal default file
field upload pops ALL files into the same directory
• Often overlooked by developers
• Significant performance impact
• Easy to prevent!
• ...not easy to fix!
Wednesday, January 15, 14
![Page 6: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/6.jpg)
Wednesday, January 15, 14
![Page 7: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/7.jpg)
https://drupal.org/node/2128055
A future fix
Wednesday, January 15, 14
![Page 8: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/8.jpg)
Not in this demo• Check out these blog posts• Adding images to your site• Inline images in Drupal 7• Responsive or Adaptive images in Drupal 7• Inline and responsive images in Drupal 8
Wednesday, January 15, 14
![Page 9: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/9.jpg)
A clean room• Protips!• Many potential conflicts with other modules
that control file system. Use clean testing sites.
• See Create a Test Site | Drupal.org
Wednesday, January 15, 14
![Page 10: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/10.jpg)
Out of the box file handling
Getting to grip with the basics
Wednesday, January 15, 14
![Page 11: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/11.jpg)
Basic settings• Global settings• Display options• Upload destination
• Per content type settings• Required?• Help text• Allowed extensions• File directory• Upload size• Description field• Progress indicator• Number of values
Wednesday, January 15, 14
![Page 12: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/12.jpg)
Limiting file types• Security tip: Err on the side of less file
extensions available to the least amount of users
Wednesday, January 15, 14
![Page 13: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/13.jpg)
Description field setting
Wednesday, January 15, 14
![Page 14: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/14.jpg)
The description
Wednesday, January 15, 14
![Page 15: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/15.jpg)
CompareWithout “description” With “description”
Wednesday, January 15, 14
![Page 16: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/16.jpg)
The “display” optionDisplay enabled Display disabled
Wednesday, January 15, 14
![Page 17: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/17.jpg)
Manage field display
Wednesday, January 15, 14
![Page 18: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/18.jpg)
Field report!
Wednesday, January 15, 14
![Page 19: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/19.jpg)
Transliteration• You NEED transliteration. Install it.• Configuration > Media > File system•
Wednesday, January 15, 14
![Page 20: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/20.jpg)
Transliteration• Configuration > Search and metadata > URL
aliases > URL aliases
Wednesday, January 15, 14
![Page 21: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/21.jpg)
Fix existing file names
Wednesday, January 15, 14
![Page 22: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/22.jpg)
How many is too many?
Wednesday, January 15, 14
![Page 23: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/23.jpg)
The extreme limits• FAT32:• Maximum number of files: 268,435,437• Maximum file size: 4GB• maximum number of files per directory: up to 65535, or less depending
on file names• NTFS:• Maximum number of files: 4,294,967,295• Maximum file size: 16TB currently (16EB theoretically)• Ext2:• Maximum number of files: 10¹⁸• Maximum file size: 2TB• theoretical file per directory limit: 1.3 × 10²⁰ files• Ext3:• Maximum number of files: number of bytes in volume/2¹³.• Maximum file size: 16GB (1KB block) to 2TB (4KB block)•http://stackoverflow.com/questions/466521/how-many-
files-in-a-directory-is-too-manyWednesday, January 15, 14
![Page 24: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/24.jpg)
What’s wrong?• Slow to load directory for maintenance and
migration• Performance hit loading files from that
directory
• Set Max at 1000 or 100,000- well below your “limit”
Wednesday, January 15, 14
![Page 25: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/25.jpg)
File path patterns
Wednesday, January 15, 14
![Page 26: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/26.jpg)
Configure file paths• Basic settings are
limited
• arbitary text
• entitytype/filetype
• Example: article/pdfs
Wednesday, January 15, 14
![Page 27: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/27.jpg)
A better idea!• sites/default/files/YYYY/MM/DD• For high volume uploads
https://drupal.org/node/2128055Wednesday, January 15, 14
![Page 28: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/28.jpg)
Token for file directory!• Set to date
Wednesday, January 15, 14
![Page 29: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/29.jpg)
File (Field) Paths• Set file name also• Node tokens• Transliteration
Wednesday, January 15, 14
![Page 30: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/30.jpg)
Example file path patterns• Parent directory by date• Parent directory by content type• Parent directory by a combination of content
type and author
Wednesday, January 15, 14
![Page 31: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/31.jpg)
Pathauto• Requires Token• Set patterns for paths instead of node/1
Wednesday, January 15, 14
![Page 32: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/32.jpg)
Private and public files
Wednesday, January 15, 14
![Page 33: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/33.jpg)
public:// & private://• Public
• Anyone can download them
• Private
• Controlling access to the files
Wednesday, January 15, 14
![Page 34: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/34.jpg)
Private• Specify a directory
outside of the doc root folder
Example../private
• OR Sub-directory under the public directory
Examplesites/default/files/private
https://drupal.org/documentation/modules/file
Wednesday, January 15, 14
![Page 35: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/35.jpg)
Private directory• Create the private directory at same level as
root folder• Configuration > Media > File system• Set file system path
• System creates .htaccess file
Wednesday, January 15, 14
![Page 36: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/36.jpg)
Choose default option• Configuration > Media > File system• Choose default method
Wednesday, January 15, 14
![Page 37: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/37.jpg)
Per field options• Select private file
• The paths will be like /system/files/ebooks/pressrelease.pdf
Wednesday, January 15, 14
![Page 38: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/38.jpg)
What happens?• Field inherits access publishing settings of
content
Wednesday, January 15, 14
![Page 39: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/39.jpg)
Private file modules• Private files download permission 1.7k using• Field Permissions 36k using • File entity (fieldable files) 29k using
Wednesday, January 15, 14
![Page 40: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/40.jpg)
More complex file handling needed?
Wednesday, January 15, 14
![Page 41: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/41.jpg)
A flexible solution• Media +
• File entity +
• OEmbed +
• CKEditor
• Being used in Drupal Commons and Demo Framework
Wednesday, January 15, 14
![Page 42: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/42.jpg)
Demo Framework• A good example of media configuration• http://drupal.org/project/df
Wednesday, January 15, 14
![Page 43: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/43.jpg)
CKEditor Link
https://drupal.org/project/ckeditor_link_filehttps://drupal.org/project/ckeditor_link
Wednesday, January 15, 14
![Page 44: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/44.jpg)
• http://drupal.org/project/multiupload_filefield_widget
• http://drupal.org/project/multiupload_imagefield_widget
• http://drupal.org/project/plupload
Multi file uploads
Wednesday, January 15, 14
![Page 45: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/45.jpg)
Future friendly
Wednesday, January 15, 14
![Page 46: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/46.jpg)
Media module 2.x• Adds an upload widget
Wednesday, January 15, 14
![Page 47: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/47.jpg)
File entity• File entity (fieldable files)• Add fields to files, group, add display modes,
use Token• Working on getting this into D8
• Documentation at drupal.org/node/1591498
Wednesday, January 15, 14
![Page 48: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/48.jpg)
Fieldable entity
Wednesday, January 15, 14
![Page 49: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/49.jpg)
File browser• File browser and uploader
Wednesday, January 15, 14
![Page 50: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/50.jpg)
File settings (global)• Configuration »
Media » File settings
• Global file field settings
Wednesday, January 15, 14
![Page 51: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/51.jpg)
Granular file permissions
Wednesday, January 15, 14
![Page 52: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/52.jpg)
Display formatter
Wednesday, January 15, 14
![Page 53: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/53.jpg)
Further extend• Media module - Handing files from external
sources and services such as YouTube, Vimeo and Flickr.
• File entity revisions module
Wednesday, January 15, 14
![Page 54: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/54.jpg)
Plans to bring into D8• Find out more “Drupal 8 media battle-plan”
groups.drupal.org/node/384813• drupal.org/community-initiatives/drupal-core/
file-management
Wednesday, January 15, 14
![Page 55: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/55.jpg)
Display formatting• Additional display formatters
Wednesday, January 15, 14
![Page 56: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/56.jpg)
Display formatting
Wednesday, January 15, 14
![Page 57: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/57.jpg)
File view modes
Wednesday, January 15, 14
![Page 58: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/58.jpg)
Fix it? HALP!
Wednesday, January 15, 14
![Page 59: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/59.jpg)
Remediation • Move files to new directories• Recreate all the files using your new tokens• If you embed “inline” files/images, you’d
have to write a script to find and replace.
• Public files are easier.• Drupal handled files are easier.• Example: Media is embedding a file ID.
Wednesday, January 15, 14
![Page 60: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/60.jpg)
Migrate Module• Use Migrate module to do an in-place
migrate of your own site.
drupal.org/project/migrateWednesday, January 15, 14
![Page 61: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/61.jpg)
Professional help• Acquia Professional Services• Migration services
Wednesday, January 15, 14
![Page 62: Preventing Drupal Headaches: Establishing Flexible File Paths From The Start](https://reader034.vdocuments.us/reader034/viewer/2022051311/5440fefcafaf9f4e208b45c6/html5/thumbnails/62.jpg)
acquia.com/resources/webinars/preventing-drupal-headaches-content-type-checklist
Wednesday, January 15, 14