You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, when using the AssetServerPlugin, it will use the LocalAssetStorageStrategy which is part of Vendure core. This storage strategy dumps all assets into a single directory.
For a very large number of files, this approach can have performance implications - thousands of files in a directory can be slower to read.
Describe the solution you'd like
We can use an approach known as a "hashed directory structure" in which a hash is made from the filename (e.g. md5) and then this hash is used to place the file in a sub-directory structure according to the first part of the hash. This is e.g. how git stores files in its /objects directory.
A reasonable way to store a small multitude of files on a file system is through a hashed directory structure with details on the files kept in a database table. One advantage of this method is that it keeps directory reads and file access times quick by not putting too many files into a single directory. source
I propose the following:
Create a new HashedDirectoryStorageStrategy
Make the storage strategy in the AssetServerPlugin configurable. This allows users to continue using the existing LocalAssetStorageStrategy to avoid breaking existing projects.
Set the new HashedDirectoryStorageStrategy as the default in the AssetServerPlugin.
Use the same approach for storing cached images - this can be hard-coded as it is an internal implementation detail of the AssetServerPlugin.
The text was updated successfully, but these errors were encountered:
Relates to #258. The developer can now provide a custom AssetStorageStrategy e.g. to store files with a cloud storage provider.
BREAKING CHANGE: The `LocalAssetStorageStrategy` class has been removed from `@vendure/core` and now lives in the `@vendure/asset-server-plugin` package.
Relates to #258. This strategy for storing files limits the total number of files in a given directory, which otherwise can impact performance when the size grows too large.
Relates to #258.
BREAKING CHANGE: The AssetServerPlugin has a new default naming strategy - instead of dumping all assets & previews into a single directory, it will now split sources & previews into subdirectories and in each of them will use hashed directories to ensure that the total number of files in a single directory does not grow too large (as this can have a negative performance impact). If you wish to keep the current behavior, then you must manually set the `namingStrategy: new DefaultAssetNamingStrategy()` in the `AssetServerPlugin.init()` method.
Is your feature request related to a problem? Please describe.
Currently, when using the
AssetServerPlugin
, it will use theLocalAssetStorageStrategy
which is part of Vendure core. This storage strategy dumps all assets into a single directory.For a very large number of files, this approach can have performance implications - thousands of files in a directory can be slower to read.
Describe the solution you'd like
We can use an approach known as a "hashed directory structure" in which a hash is made from the filename (e.g. md5) and then this hash is used to place the file in a sub-directory structure according to the first part of the hash. This is e.g. how git stores files in its
/objects
directory.I propose the following:
HashedDirectoryStorageStrategy
LocalAssetStorageStrategy
to avoid breaking existing projects.HashedDirectoryStorageStrategy
as the default in the AssetServerPlugin.The text was updated successfully, but these errors were encountered: