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

@amplication/plugin-storage-core

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-core

Adds the core functionality for file upload to Amplication

  • 0.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
6K
decreased by-1.28%
Maintainers
7
Weekly downloads
 
Created
Source

@amplication/plugin-storage-core

NPM Downloads

Purpose

This plugin is used for integrating storage services into your app generated by Amplication. The plugin will add the required core functionality on top of which other storage services can be built.

[!CAUTION] The other storage plugins should have plugin ids of the form storage-<provider> and should be added through the plugins page of the app settings before adding this plugin to get the expected functionality.

Working with the plugin

It can be used by adding the plugin in the plugins page of the app settings. For this plugin, no additional settings are required.

[!NOTE] There should be enitities with fields of data type File for this plugin to generate any additional functionality.

What the plugin does

Adds resolver and controller methods

The following methods are added for each field of type File in the entities:

Resolver methods:

  • upload< FieldName in PascalCase >: Upload a file to the storage service.
  • delete< FieldName in PascalCase >: Delete the file from the storage service.

Controller methods:

  • upload< FieldName in PascalCase >: Upload a file to the storage service.
  • delete< FieldName in PascalCase >: Delete the file from the storage service.
  • download< FieldName in PascalCase >: Download the file from the storage service.

Generates the configuration for file upload services

It adds graphqlUploadExpress middleware to the express app to let the app handle file uploads.

Adds the storage core service abstract class

The plugin adds the StorageService abstract class which can be extended to create storage services for different storage providers. The class does the following:

  • Checks if the file is of the correct mimetype and size.
  • Generates a unique file name.
  • Gives proper mime type while downloading the file.

How is file upload handled?

When a file is uploaded, the file is saved through the storage service and the following JSON is saved in the database:

{
  "uuid": "/path/to/file", // UUID for the file (can be used to retrieve the file eg. URL or file path)
  "filename": "profilePicture-<id of entity>",
  "mimetype": "image/jpeg",
  "encoding": "7bit",
  "size": 123456, // File size in bytes
  "metadata": {} // Provider specific metadata
}

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