file_access_via_webform
Introduction
The File Access Via Webform module allows Drupal site administrators to securely share files through webforms. It uses token-based access to ensure only authorized users can download sensitive files, making it ideal for beginners managing file access. This module provides a simple, user-friendly solution for protecting documents while collecting user information via webforms.
Features
What is the basic functionality?
This module enables secure file downloads through Drupal webforms. Users must submit a webform to access a file, and the module uses tokens to verify access, preventing unauthorized downloads.
What unique features does enabling this project add?
- Token-based security: Protects files with unique, temporary access tokens.
- Customizable download behavior: Choose whether files open in the browser or download automatically.
- Webform integration: Links file access to webforms for user data collection.
- Custom messages: Display tailored messages after downloads.
- Modal dialogs: Optional Bootstrap 4 Modal for a polished user experience.
- Field formatter: Adds a “Webform Download Button” for file fields.
- Media support: Works with direct file fields and media document references.
When and why would someone use this module?
Use this module to securely distribute files like PDFs, reports, or proprietary documents while collecting user information. It’s ideal for sites needing user verification before granting file access, such as gated content or client resources.
What use cases are there?
- A company sharing whitepapers after users submit contact details.
- A university providing lecture notes to registered students.
- A nonprofit distributing secure reports to donors via a webform.
Post-Installation
Once installed, the module adds a “Webform Download Button” formatter for file fields and a “File Access Download Redirect” handler for webforms. Users click a button to access a webform, submit it, and receive a secure download link.
Configuration process
- Set up the field formatter:
- Go to
/admin/structure/types(Structure > Content types). - Select your content type, then click “Manage display.”
- For your file field, choose the “Webform Download Button” formatter.
- Configure settings:
- Modal width: Set dialog size (e.g., “800px”).
- Link text: Customize button text (e.g., “Download Now”).
- Show header/title: Toggle modal header visibility.
- Webform: Select the webform for access control.
- Go to
- Configure the webform handler:
- Go to
/admin/structure/webform(Structure > Webforms). - Select or create a webform, then go to “Settings” > “Handlers.”
- Add the “File Access Download Redirect” handler.
- Configure settings:
- File disposition: Choose “inline” (view in browser) or “attachment” (force download).
- Download message: Set a custom message (e.g., “Your file is downloading…”).
- File URL security: Select “enhanced” for token-based URLs or “standard” for direct URLs.
- Debug mode: Enable for troubleshooting (disable in production).
- Go to
- Test the setup:
- Create a node with a file field and the configured formatter.
- Visit the node, click the download button, submit the webform, and verify the file downloads.
Special considerations
- Ensure the webform is accessible to intended users (check permissions at
/admin/people/permissions). - If using modals, test responsiveness for mobile users.
- Review logs at
/admin/reports/dblogfor errors (e.g., invalid webform settings).
Recommended Modules/Libraries
- Bootstrap 4 Modal: Enhances the module with modal dialogs for a better user experience (
composer require drupal/bootstrap4_modal). - Drupal.org Issue Queue: Report bugs or suggest features at drupal.org/project/file_access_via_webform.
- Contribute: Submit patches or help with documentation via the issue queue.
- YouTube Walkthrough: File Access Via Webform Setup Guide (coming soon).
Supporting this Module
Support development through:
Community Documentation