Upload directory structure and performance

Hello,

Examining the code (and running some simple tests) reveals that Axelor is storing all uploaded files (attachments) in a single flat directory. This may me OK if you only need to store an occasional attachment once in a while. In my case however it is necessary to store between 2 and 10 (or sometimes even more) attachments on every quotation and/or sales order. This can result in several hundred thousands of files stored in a single directory, which will lead to performance issues (to what extent , it depends on the type of file system)

I would like to create a module to override the default storage scheme and split the files among several subdirectories but the class responsible for this (com.axelor.meta.MetaFiles) uses static methods to calculate the file path to store the uploaded file.

How can I override this?

1 « J'aime »

Hi,
For 1 batch I create a method to create subfolder with batch names.
So it create a subfolder everytime.

Hello,

It is possible to save the files in separate folders using a pattern.

https://docs.axelor.com/adk/5.4/dev-guide/application/config.html#example-configuration

# Upload filename pattern, default is auto where file is save with same name
# in the given upload dir, if file is already there, a count number is
# appended to file name.
#
# This can be overridden by providing custom name pattern, for example:
#
#   file.upload.filename.pattern = {year}-{month}/{day}/{name}
#   file.upload.filename.pattern = {AA}/{name}
#
# Following placeholders can be used:
#
# {year} - current year
# {month} - current month
# {day} - current day
# {name} - file name
# {A} - first letter from file name
# {AA} - first 2 letter from file name
# {AAA} - first 3 letter from file name
#
#file.upload.filename.pattern = {year}-{month}/{day}/{name}

Regards

1 « J'aime »

That’s great!

Thanks for the pointer, I wouldn’t have though to look at the configuration in dev docs (although it is rather obvious I should have)

Hi @gdu-axelor
Is possible alsu using other placeholer, for example Timesheet Employees or something else?
I mean all file attached from employees goes in a folder for employees as well as for employee name.

Ce sujet a été automatiquement fermé après 30 jours. Aucune réponse n’est permise dorénavant.