@amplication/plugin-storage-local
Purpose
This plugin is used for integrating local storage services into your app generated by Amplication.
Configuration
The plugin has the following configuration options:
- fileBasePath: The base path where the files will be stored. The default value is
./uploads
. - maxFileSize: The maximum file size in bytes. The default value is
10485760
(10MB).
Example configuration:
{
"fileBasePath": "./uploads",
"maxFileSize": 10485760
}
[!CAUTION]
The storage-core plugin should be added through the plugins page of the app settings before adding this plugin. Else code generation will fail and throw an error.
What the plugin does
Adds service methods
It adds the following service methods for each field of type File
in the entities:
Provides the local storage methods
-
uploadFile: This method is used to upload a file to the local storage. It takes the following parameters:
- file: The file to be uploaded.
- extension: The file mimeypes allowed for the file.
- basePath: The base path where the file will be stored. If not provided, the default value from the configuration will be used.
- maxFileSize: The maximum file size in bytes. If not provided, the default value from the configuration will be used.
-
deleteFile: This method is used to delete a file from the local storage.
-
downloadFile: This method is used to download a file from the local storage.
[!CAUTION]
In case of extensions being empty, no file will be uploaded and an error will be thrown.
Scripts
build
Running npm run build
will bundle your plugin with Webpack for production.
dev
Running npm run dev
will watch your plugin's source code and automatically bundle it with every change.