Prevent Drupal Headaches

FLEXIBLE FILE PATHS
FROM THE START

Wednesday, January 15, 14
training.acquia.com/events

Wednesday, January 15, 14
Who is this for?
•
•

New to Drupal?

•

Inherited a new
Drupal site and want
to know more about
configuration

Starting a ...
In this demo
•

How file path patterns
affect maintenance and
migrations

•

File upload
management

•

Future friendly pat...
Source of the pain?
•

Drupal default file
field upload pops
ALL files into the
same directory

•

Often overlooked by
develo...
Wednesday, January 15, 14
A future fix

https://drupal.org/node/2128055
Wednesday, January 15, 14
Not in this demo
• Check out these blog posts
• Adding images to your site
• Inline images in Drupal 7
• Responsive or Ada...
A clean room
• Protips!
• Many potential conflicts with other modules

that control file system. Use clean testing
sites.
• ...
Getting to grip with the basics

Out of the box file
handling

Wednesday, January 15, 14
Basic settings
•

Global settings

•
•
•

Display options
Upload destination
Per content type settings

•
•
•
•
•
•
•
•

R...
Limiting file types
• Security tip: Err on the side of less file

extensions available to the least amount of
users

Wednes...
Description field setting

Wednesday, January 15, 14
The description

Wednesday, January 15, 14
Compare
Without “description”

Wednesday, January 15, 14

With “description”
The “display” option
Display enabled

Wednesday, January 15, 14

Display disabled
Manage field display

Wednesday, January 15, 14
Field report!

Wednesday, January 15, 14
Transliteration
• You NEED transliteration. Install it.
• Configuration > Media > File system
•

Wednesday, January 15, 14
Transliteration
• Configuration > Search and metadata > URL

aliases > URL aliases

Wednesday, January 15, 14
Fix existing file names

Wednesday, January 15, 14
How many is too
many?

Wednesday, January 15, 14
The extreme limits
• FAT32:
• Maximum number of files: 268,435,437
• Maximum file size: 4GB
• maximum number of files per dir...
What’s wrong?
• Slow to load directory for maintenance and

migration
• Performance hit loading files from that

directory
...
File path patterns

Wednesday, January 15, 14
Configure file paths
•

Basic settings are
limited

•
•

arbitary text
entitytype/filetype

•

Example:
article/pdfs

Wedne...
A better idea!
• sites/default/files/YYYY/MM/DD
• For high volume uploads

https://drupal.org/node/2128055
Wednesday, Janua...
Token for file directory!
• Set to date

Wednesday, January 15, 14
File (Field) Paths
• Set file name also
• Node tokens
• Transliteration

Wednesday, January 15, 14
Example file path patterns
• Parent directory by date
• Parent directory by content type
• Parent directory by a combinati...
Pathauto
• Requires Token
• Set patterns for paths instead of node/1

Wednesday, January 15, 14
Private and
public files

Wednesday, January 15, 14
public:// & private://
•
•

Public

•
•

Private

Anyone can
download them

Controlling access to
the files

Wednesday, Jan...
Private
• Specify a directory

• OR Sub-directory

outside of the doc
root folder

under the public
directory

Example

Ex...
Private directory
• Create the private directory at same level as

root folder
• Configuration > Media > File system
• Set ...
Choose default option
• Configuration > Media > File system
• Choose default method

Wednesday, January 15, 14
Per field options
• Select private file

• The paths will be like

/system/files/ebooks/pressrelease.pdf

Wednesday, January...
What happens?
• Field inherits access publishing settings of

content

Wednesday, January 15, 14
Private file modules
• Private files download permission 1.7k using
• Field Permissions 36k using
• File entity (fieldable fi...
More complex file
handling needed?

Wednesday, January 15, 14
A flexible solution
•
•
•
•

Media +

•

Being used in Drupal
Commons and Demo
Framework

File entity +
OEmbed +
CKEditor
...
Demo Framework
• A good example of media configuration
• http://drupal.org/project/df

Wednesday, January 15, 14
CKEditor Link

https://drupal.org/project/ckeditor_link_file
https://drupal.org/project/ckeditor_link
Wednesday, January 1...
Multi file uploads
• http://drupal.org/project/

multiupload_filefield_widget
• http://drupal.org/project/

multiupload_imag...
Future friendly

Wednesday, January 15, 14
Media module 2.x
• Adds an upload widget

Wednesday, January 15, 14
File entity
• File entity (fieldable files)
• Add fields to files, group, add display modes,

use Token
• Working on getting t...
Fieldable entity

Wednesday, January 15, 14
File browser
• File browser and uploader

Wednesday, January 15, 14
File settings (global)
•

Configuration »
Media » File
settings

•

Global file field
settings

Wednesday, January 15, 14
Granular file permissions

Wednesday, January 15, 14
Display formatter

Wednesday, January 15, 14
Further extend
• Media module - Handing files from external

sources and services such as YouTube,
Vimeo and Flickr.
• File...
Plans to bring into D8
• Find out more “Drupal 8 media battle-plan”

groups.drupal.org/node/384813
• drupal.org/community-...
Display formatting
• Additional display formatters

Wednesday, January 15, 14
Display formatting

Wednesday, January 15, 14
File view modes

Wednesday, January 15, 14
Fix it? HALP!

Wednesday, January 15, 14
Remediation
• Move files to new directories
• Recreate all the files using your new tokens
• If you embed “inline” files/imag...
Migrate Module
• Use Migrate module to do an in-place

migrate of your own site.

drupal.org/project/migrate
Wednesday, Ja...
Professional help
• Acquia Professional Services
• Migration services

Wednesday, January 15, 14
acquia.com/resources/webinars/
preventing-drupal-headaches-content-type-checklist
Wednesday, January 15, 14
Upcoming SlideShare
Loading in...5
×

Preventing Drupal Headaches: Establishing Flexible File Paths From The Start

9,723

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,723
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
54
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Preventing Drupal Headaches: Establishing Flexible File Paths From The Start

  1. 1. Prevent Drupal Headaches FLEXIBLE FILE PATHS FROM THE START Wednesday, January 15, 14
  2. 2. training.acquia.com/events Wednesday, January 15, 14
  3. 3. Who is this for? • • New to Drupal? • Inherited a new Drupal site and want to know more about configuration Starting a new Drupal site! Wednesday, January 15, 14
  4. 4. In this demo • How file path patterns affect maintenance and migrations • File upload management • Future friendly path patterns Wednesday, January 15, 14
  5. 5. 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
  6. 6. Wednesday, January 15, 14
  7. 7. A future fix https://drupal.org/node/2128055 Wednesday, January 15, 14
  8. 8. 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
  9. 9. 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
  10. 10. Getting to grip with the basics Out of the box file handling Wednesday, January 15, 14
  11. 11. 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
  12. 12. Limiting file types • Security tip: Err on the side of less file extensions available to the least amount of users Wednesday, January 15, 14
  13. 13. Description field setting Wednesday, January 15, 14
  14. 14. The description Wednesday, January 15, 14
  15. 15. Compare Without “description” Wednesday, January 15, 14 With “description”
  16. 16. The “display” option Display enabled Wednesday, January 15, 14 Display disabled
  17. 17. Manage field display Wednesday, January 15, 14
  18. 18. Field report! Wednesday, January 15, 14
  19. 19. Transliteration • You NEED transliteration. Install it. • Configuration > Media > File system • Wednesday, January 15, 14
  20. 20. Transliteration • Configuration > Search and metadata > URL aliases > URL aliases Wednesday, January 15, 14
  21. 21. Fix existing file names Wednesday, January 15, 14
  22. 22. How many is too many? Wednesday, January 15, 14
  23. 23. 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-manyfiles-in-a-directory-is-too-many Wednesday, January 15, 14
  24. 24. 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
  25. 25. File path patterns Wednesday, January 15, 14
  26. 26. Configure file paths • Basic settings are limited • • arbitary text entitytype/filetype • Example: article/pdfs Wednesday, January 15, 14
  27. 27. A better idea! • sites/default/files/YYYY/MM/DD • For high volume uploads https://drupal.org/node/2128055 Wednesday, January 15, 14
  28. 28. Token for file directory! • Set to date Wednesday, January 15, 14
  29. 29. File (Field) Paths • Set file name also • Node tokens • Transliteration Wednesday, January 15, 14
  30. 30. 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
  31. 31. Pathauto • Requires Token • Set patterns for paths instead of node/1 Wednesday, January 15, 14
  32. 32. Private and public files Wednesday, January 15, 14
  33. 33. public:// & private:// • • Public • • Private Anyone can download them Controlling access to the files Wednesday, January 15, 14
  34. 34. Private • Specify a directory • OR Sub-directory outside of the doc root folder under the public directory Example Example ../private sites/default/ files/private https://drupal.org/documentation/modules/file Wednesday, January 15, 14
  35. 35. 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
  36. 36. Choose default option • Configuration > Media > File system • Choose default method Wednesday, January 15, 14
  37. 37. Per field options • Select private file • The paths will be like /system/files/ebooks/pressrelease.pdf Wednesday, January 15, 14
  38. 38. What happens? • Field inherits access publishing settings of content Wednesday, January 15, 14
  39. 39. Private file modules • Private files download permission 1.7k using • Field Permissions 36k using • File entity (fieldable files) 29k using Wednesday, January 15, 14
  40. 40. More complex file handling needed? Wednesday, January 15, 14
  41. 41. A flexible solution • • • • Media + • Being used in Drupal Commons and Demo Framework File entity + OEmbed + CKEditor Wednesday, January 15, 14
  42. 42. Demo Framework • A good example of media configuration • http://drupal.org/project/df Wednesday, January 15, 14
  43. 43. CKEditor Link https://drupal.org/project/ckeditor_link_file https://drupal.org/project/ckeditor_link Wednesday, January 15, 14
  44. 44. Multi file uploads • http://drupal.org/project/ multiupload_filefield_widget • http://drupal.org/project/ multiupload_imagefield_widget • http://drupal.org/project/plupload Wednesday, January 15, 14
  45. 45. Future friendly Wednesday, January 15, 14
  46. 46. Media module 2.x • Adds an upload widget Wednesday, January 15, 14
  47. 47. 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
  48. 48. Fieldable entity Wednesday, January 15, 14
  49. 49. File browser • File browser and uploader Wednesday, January 15, 14
  50. 50. File settings (global) • Configuration » Media » File settings • Global file field settings Wednesday, January 15, 14
  51. 51. Granular file permissions Wednesday, January 15, 14
  52. 52. Display formatter Wednesday, January 15, 14
  53. 53. 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
  54. 54. 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
  55. 55. Display formatting • Additional display formatters Wednesday, January 15, 14
  56. 56. Display formatting Wednesday, January 15, 14
  57. 57. File view modes Wednesday, January 15, 14
  58. 58. Fix it? HALP! Wednesday, January 15, 14
  59. 59. 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
  60. 60. Migrate Module • Use Migrate module to do an in-place migrate of your own site. drupal.org/project/migrate Wednesday, January 15, 14
  61. 61. Professional help • Acquia Professional Services • Migration services Wednesday, January 15, 14
  62. 62. acquia.com/resources/webinars/ preventing-drupal-headaches-content-type-checklist Wednesday, January 15, 14
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×