Project

General

Profile

Actions

Feature #103594

open

Allow specific file extensions per File Storage

Added by Marcelo Vetter 8 months ago. Updated 8 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2024-04-10
Due date:
% Done:

0%

Estimated time:
PHP Version:
8.1
Tags:
FAL, Block File Extension
Complexity:
easy
Sprint Focus:

Description

Let's image we have two File Storages set up:
  • Documents (/fileadmin/documents/*)
  • Images (/fileadmin/images/*)
I would like to only allow specific file types per File Storage:
  • Documents (.pdf, .doc, .docx, .etc...)
  • Images (.jpg, .jpeg, .png, .gif, .webp, .etc...)

I've created a simple BeforeFileAddedEvent listener (which I'm attaching here as an example). Below is a sample PageTS Config on the Page ID 1 Resources tab or on the user or user group Options tab:

permissions.file.storage {

  // 1 = Images Storage ID
  1 {
    allowedExtensions = jpg|jpeg|png|webp|gif|svg
    allowedExtensionsMsg = To upload a document, please use the Documents drive.
  }

  // 5 = Documents Storage ID
  5 {
    allowedExtensions = pdf|docx|doc|csv|xlsx|xls|pptx|ppt
    allowedExtensionsMsg = To upload an image, please use the Images drive.
  }

}

Is it doable to include something similar in the core of TYPO3?

Thanks!


Files

StorageExtensionBlocker.php (3.95 KB) StorageExtensionBlocker.php BeforeFileAddedEvent PHP file example Marcelo Vetter, 2024-04-10 21:37
Actions

Also available in: Atom PDF