Name:
interface
Value:
Extend your Amplify Gen 2 app with AWS Blocks — self-contained backend capabilities you compose into your existing backend.

Page updated Apr 29, 2024

NewDeploy web apps with Git or your AI coding agent using the latest AWS Amplify. Add managed databases and authentication as you grow. Explore the documentation.
Maintenance ModeYou are viewing Amplify Gen 1 documentation. Amplify Gen 1 has entered maintenance mode and will reach end of life on May 1, 2027. For existing Gen 1 projects, a migration guide and tooling are available to help you upgrade.
JavaScript v5Amplify JavaScript v5 has entered maintenance mode. We recommend upgrading to v6. A migration guide is available to help you upgrade from v5 to v6.

Custom Plugin

These docs cover Amplify Gen 1. For new web apps, we recommend the latest AWS Amplify, with a simplified CLI and native integrations for databases, storage, and AI models. Get started with the latest AWS Amplify.

You can create your custom pluggable for Storage. This may be helpful if you want to integrate your app with a custom storage backend.

To create a plugin implement the StorageProvider interface:

import { Storage, StorageProvider } from 'aws-amplify';
export default class MyStorageProvider implements StorageProvider {
// category and provider name
static category = 'Storage';
static providerName = 'MyStorage';
// you need to implement these seven methods
// configure your provider
configure(config: object): object;
// copy object, optional
copy?(
src: { key: string; identityId: string; level: 'public' | 'protected' | 'private' },
dest: { key: string; level: 'public' | 'protected' | 'private' },
options?
): Promise<any>
// get object/pre-signed url from storage
get(key: string, options?): Promise<String|Object>
// upload storage object
put(key: string, object, options?): Promise<Object>
// remove object
remove(key: string, options?): Promise<any>
// list objects for the path
list(path, options?): Promise<any>
// return 'Storage';
getCategory(): string;
// return the name of you provider
getProviderName(): string;

You can now register your pluggable:

// add the plugin
Storage.addPluggable(new MyStorageProvider());
// get the plugin
Storage.getPluggable(MyStorageProvider.providerName);
// remove the plugin
Storage.removePluggable(MyStorageProvider.providerName);
// send configuration into Amplify
Storage.configure({
[MyStorageProvider.providerName]: {
// My Storage provider configuration
}
});

You can pass in your custom provider class to the Storage function to get Typescript support:

class MyStorageProvider implements StorageProvider {
...
get(key: string, config: { config1: number; }): Promise<{ key: string }>;
}
// will automatically use the return type from the provider's function signature
const getResult: Promise<{ key: string }> = Storage.get<MyStorageProvider>('key', {
provider: 'MyStorage',
config1: 123,
});

The default provider (Amazon S3) is in use when you call Storage.put( ) unless you specify a different provider: Storage.put(key, object, {provider: 'MyStorage'}).