Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@amplication/plugin-storage-local

Package Overview
Dependencies
Maintainers
7
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amplication/plugin-storage-local

Adds the local storage functionality for file upload to Amplication

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

@amplication/plugin-storage-local

NPM Downloads

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:

  • upload: This method takes a file and uses the following name schmea to store the file: <fieldName>-<entityId>-<fileName>. ( eg: profileImage-1-image.png )

  • delete

  • download

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.

FAQs

Package last updated on 29 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc