Problem/Motivation

Putting a lot of files into the same directory is bad for file system performance.

Proposed resolution

Support tokens in the upload_location field, just like a file field.

Also, I think it makes sense to adopt the file field default, which uses the year and month as default location.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Status: Active » Needs review
FileSize
1.75 KB
Primsi’s picture

Status: Needs review » Needs work
+++ b/src/DropzoneJsUploadSave.php
@@ -100,6 +101,10 @@ class DropzoneJsUploadSave implements DropzoneJsUploadSaveInterface {
+    $destination = PlainTextOutput::renderFromHtml(\Drupal::token()->replace($destination));

Inject the token service?

Otherwise looks fine.

tduong’s picture

Status: Needs work » Needs review
FileSize
2.51 KB
3.79 KB

Added token service injection.

Berdir’s picture

Status: Needs review » Needs work
+++ b/src/DropzoneJsUploadSave.php
@@ -83,14 +93,26 @@ class DropzoneJsUploadSave implements DropzoneJsUploadSaveInterface {
+  public static function create(ContainerInterface $container) {
+    return new static(
+      $container->get('token')
+      );

You don't need this. You need to add it to dropzonejs.services.yml instead.

tduong’s picture

Status: Needs work » Needs review
FileSize
1.28 KB
4.17 KB

Done.

Berdir’s picture

Looks good to me now but haven't tested.

  • Primsi committed 6dba258 on 8.x-1.x
    Issue #2661402 by tduong, Berdir, Primsi: Support tokens in...
Primsi’s picture

Status: Needs review » Fixed

Tested it, looks fine. Thanks all.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.