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. In this demo
•
How file path patterns
affect maintenance and
migrations
•
File upload
management
•
Future friendly path
patterns
Wednesday, January 15, 14
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
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. 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. Getting to grip with the basics
Out of the box file
handling
Wednesday, January 15, 14
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. Limiting file types
• Security tip: Err on the side of less file
extensions available to the least amount of
users
Wednesday, January 15, 14
22. How many is too
many?
Wednesday, January 15, 14
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. 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
26. Configure file paths
•
Basic settings are
limited
•
•
arbitary text
entitytype/filetype
•
Example:
article/pdfs
Wednesday, January 15, 14
27. A better idea!
• sites/default/files/YYYY/MM/DD
• For high volume uploads
https://drupal.org/node/2128055
Wednesday, January 15, 14
28. Token for file directory!
• Set to date
Wednesday, January 15, 14
29. File (Field) Paths
• Set file name also
• Node tokens
• Transliteration
Wednesday, January 15, 14
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
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. 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. Choose default option
• Configuration > Media > File system
• Choose default method
Wednesday, January 15, 14
37. Per field options
• Select private file
• The paths will be like
/system/files/ebooks/pressrelease.pdf
Wednesday, January 15, 14
38. What happens?
• Field inherits access publishing settings of
content
Wednesday, January 15, 14
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
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
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. 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
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. Migrate Module
• Use Migrate module to do an in-place
migrate of your own site.
drupal.org/project/migrate
Wednesday, January 15, 14