Amplication
Platform
Solutions
Learn
Star Us 12.7K
Log In to Amplication

Contact us

  • contact@amplication.org
Try Overcut.ai
  • Home /
  • Plugins /
  • Storage Core
plugin logo
Storage Core
Install Plugin

@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.

Details
npm
@amplication/plugin-storage-core
github
https://github.com/amplication/plugins/tree/main/plugins/storage-core
Installs
0
Categories
Storage
Documentation
https://github.com/amplication/plugins/tree/main/plugins/storage-core

Get started with Amplication and Storage Core

Start NowBook a demo

Platform

Live TemplatesPluginsJovu

Solutions

Enhance platform engineeringBuild new servicesBuild APIs on existing DBModernize applications

Customers

IT ServicesRetailHealthcareManufacturingCustomer stories

Use Amplication

Get started Custom pluginsCustom codeSync with GitEvent-driven architectureBreak the monolith

Resources

DocsCustomer storiesPlugins catalogDiscord communityGitHubBlog

About

CompanyContact us

©2025 amplication

Privacy PolicyTerms & Conditions
Follow usTwitter IconYouTube Icon