Take Control of File I/O with Stream Wrappers

PHP provides an useful abstraction for managing file I/O called stream wrappers and defines an interface for developers to utilize. Drupal extends PHP’s native interface, creates multiple wrappers in core, and allows you to register your own. Come learn how to write custom stream wrappers that give you control of what happens to files when Drupal saves and loads them.

Discover how to create your own URI schemes that sit alongside public:// and private://, as well as learn how core uses wrappers for its schemes and how you can learn from and extend them. The goal of this talk is to give you an understanding of how stream wrappers are built, how PHP and Drupal use them, and how you can use them to store files where and how you wish.

In addition to the above information, I’ll introduce you to a real-life example, Encrypted Files, which I plan to submit as a full drupal.org project before DrupalCon. With this example, I’ll illustrate for you how stream wrappers can be used to implement interesting and practical solutions. For a sneak peek, check out the Encrypted Files sandbox project on drupal.org:
http://drupal.org/sandbox/whastings/1873916

Topics Covered:

  • Creating classes that implement the DrupalStreamWrapperInterface
  • Registering a custom URI scheme with hook_stream_wrappers()
  • Studying the stream wrappers provided by Drupal core
  • Considering the use case of encrypting and decrypting files via a stream wrapper
Schedule info
Status: 
Proposed
Session Info
Speaker(s): 
Track: 
Coding + Development
Experience level: 
Intermediate

Comments

This has been a huge need for us; the sandbox project helped us implement a document server with stringent security requirements. Excited to see this topic get more press so more junior devs can learn about accessible tools to encrypt files.

We've used this in production and it works great.

It is amazing to me that there is no out of the box way to get a jump start on doing some of this important security stuff.

Drupal has needed someone to talk about, and provide accesible solutions to this area for awhile.

I need to learn more about stream wrappers and the encrypted files example sounds like something I could use. I will be at this talk.