@aws-amplify/storage
- Version 5.1.1
- Published
- 553 kB
- 8 dependencies
- Apache-2.0 license
Install
npm i @aws-amplify/storage
yarn add @aws-amplify/storage
pnpm add @aws-amplify/storage
Overview
Storage category of aws-amplify
Index
Variables
Classes
Interfaces
Type Aliases
- CommonStorageOptions
- CustomPrefix
- PutResult
- ResumableUploadConfig
- S3ClientOptions
- S3CopyDestination
- S3CopySource
- S3ProviderCopyConfig
- S3ProviderCopyOutput
- S3ProviderGetConfig
- S3ProviderGetOuput
- S3ProviderListConfig
- S3ProviderListOutput
- S3ProviderPutConfig
- S3ProviderPutOutput
- S3ProviderRemoveConfig
- S3ProviderRemoveOutput
- StorageAccessLevel
- StorageCopyConfig
- StorageCopyDestination
- StorageCopyOutput
- StorageCopySource
- StorageCopyTarget
- StorageGetConfig
- StorageGetOutput
- StorageListConfig
- StorageListOutput
- StorageOperationConfigMap
- StorageProviderApi
- StoragePutConfig
- StoragePutOutput
- StorageRemoveConfig
- StorageRemoveOutput
Variables
variable Storage
const Storage: Storage;
Classes
class AWSS3Provider
class AWSS3Provider implements StorageProvider {}
Provide storage methods to use AWS S3
constructor
constructor(config?: StorageOptions);
Initialize Storage with AWS configurations
Parameter config
Configuration object for storage
property CATEGORY
static readonly CATEGORY: string;
property PROVIDER_NAME
static readonly PROVIDER_NAME: string;
method configure
configure: (config?: any) => object;
Configure Storage part with aws configuration
Parameter config
Configuration of the Storage {Object} - Current configuration
method copy
copy: ( src: S3CopySource, dest: S3CopyDestination, config?: S3ProviderCopyConfig) => Promise<S3ProviderCopyOutput>;
Copy an object from a source object to a new object within the same bucket. Can optionally copy files across different level or identityId (if source object's level is 'protected').
Parameter src
Key and optionally access level and identityId of the source object.
Parameter dest
Key and optionally access level of the destination object.
Parameter config
Optional configuration for s3 commands. {Promise} The key of the copied object.
method get
get: < T extends CommonStorageOptions & { download?: boolean; track?: boolean; expires?: number; provider?: 'AWSS3'; identityId?: string; progressCallback?: (progress: any) => any; cacheControl?: GetObjectRequest; contentDisposition?: GetObjectRequest; contentEncoding?: GetObjectRequest; contentLanguage?: GetObjectRequest; contentType?: GetObjectRequest; SSECustomerAlgorithm?: GetObjectRequest; SSECustomerKey?: GetObjectRequest; SSECustomerKeyMD5?: GetObjectRequest; } & StorageOptions>( key: string, config?: T) => Promise<S3ProviderGetOuput<T>>;
Get a presigned URL of the file or the object data when download:true
Parameter key
key of the object
Parameter config
Optional configuration for the underlying S3 command {Promise<string | GetObjectCommandOutput>} - A promise resolves to Amazon S3 presigned URL or the GetObjectCommandOutput if download is set to true on success
method getCategory
getCategory: () => string;
get the category of the plugin
method getProviderName
getProviderName: () => 'AWSS3';
get provider name of the plugin
method list
list: ( path: string, config?: S3ProviderListConfig) => Promise<S3ProviderListOutput>;
List bucket objects relative to the level and prefix specified
Parameter path
the path that contains objects
Parameter config
Optional configuration for the underlying S3 command {Promise} - Promise resolves to list of keys, eTags, lastModified and file size for all objects in path
method put
put: <T extends S3ProviderPutConfig>( key: string, object: PutObjectCommandInput, config?: T) => S3ProviderPutOutput<T>;
Put a file in S3 bucket specified to configure method
Parameter key
key of the object
Parameter object
File to be put in Amazon S3 bucket
Parameter config
Optional configuration for the underlying S3 command an instance of AWSS3UploadTask or a promise that resolves to an object with the new object's key on success.
method remove
remove: ( key: string, config?: S3ProviderRemoveConfig) => Promise<S3ProviderRemoveOutput>;
Remove the object for specified key
Parameter key
key of the object
Parameter config
Optional configuration for the underlying S3 command {Promise} - Promise resolves upon successful removal of the object
class StorageClass
class Storage {}
Provide storage methods to use AWS S3
constructor
constructor();
Initialize Storage
Parameter config
Configuration object for storage
property vault
vault: Storage;
Modifiers
@public
method addPluggable
addPluggable: (pluggable: StorageProvider) => {};
add plugin into Storage category
Parameter pluggable
an instance of the plugin
method cancel
cancel: { (request: UploadTask, message?: string): Promise<boolean>; (request: Promise<any>, message?: string): void;};
Cancels an inflight request
Parameter request
The request to cancel
Parameter message
A message to include in the cancelation exception
method configure
configure: (config?: any) => any;
Configure Storage
Parameter config
Configuration object for storage {Object} - Current configuration
method copy
copy: <T extends Record<string, any>>( src: StorageCopySource, dest: StorageCopyDestination, config?: StorageCopyConfig<T>) => StorageCopyOutput<T>;
Copies a file from src to dest.
Parameter src
The source object.
Parameter dest
The destination object.
Parameter config
config for the Storage operation. A promise resolves to the copied object's key.
method get
get: <T extends Record<string, any> & { download?: boolean }>( key: string, config?: StorageGetConfig<T>) => StorageGetOutput<T>;
Get a presigned URL of the file or the object data when download:true
Parameter key
key of the object
Parameter config
config for the Storage operation. - A promise resolves to either a presigned url or the object
method getModuleName
getModuleName: () => string;
method getPluggable
getPluggable: (providerName: string) => StorageProvider;
Get the plugin object
Parameter providerName
the name of the plugin
method isCancelError
isCancelError: (error: any) => boolean;
method list
list: <T extends Record<string, any>>( key: string, config?: StorageListConfig<T>) => StorageListOutput<T>;
List bucket objects relative to the level and prefix specified
Parameter path
the path that contains objects
Parameter config
- Promise resolves to list of keys for all objects in path
method put
put: <T extends Record<string, any>>( key: string, object: any, config?: StoragePutConfig<T>) => StoragePutOutput<T>;
Put a file in storage bucket specified to configure method
Parameter key
key of the object
Parameter object
File to be put in bucket
Parameter config
- promise resolves to object on success
method remove
remove: <T extends Record<string, any>>( key: string, config?: StorageRemoveConfig<T>) => StorageRemoveOutput<T>;
Remove the object for specified key
Parameter key
key of the object
Parameter config
- Promise resolves upon successful removal of the object
method removePluggable
removePluggable: (providerName: string) => void;
Remove the plugin object
Parameter providerName
the name of the plugin
Interfaces
interface FileMetadata
interface FileMetadata {}
property bucket
bucket: string;
property fileName
fileName: string;
property key
key: string;
property lastTouched
lastTouched: number;
property uploadId
uploadId: string;
interface S3CopyTarget
interface S3CopyTarget {}
property identityId
identityId?: string;
property key
key: string;
property level
level?: StorageAccessLevel;
interface S3ProviderListOutputItem
interface S3ProviderListOutputItem {}
property eTag
eTag: ListObjectsCommandOutputContent['ETag'];
property key
key: ListObjectsCommandOutputContent['Key'];
property lastModified
lastModified: ListObjectsCommandOutputContent['LastModified'];
property size
size: ListObjectsCommandOutputContent['Size'];
interface StorageOptions
interface StorageOptions {}
property bucket
bucket?: string;
property credentials
credentials?: ICredentials;
property customPrefix
customPrefix?: CustomPrefix;
Custom mapping of your prefixes. For example, customPrefix: { public: 'myPublicPrefix' } will make public level operations access 'myPublicPrefix/' instead of the default 'public/'.
property dangerouslyConnectToHttpEndpointForTesting
dangerouslyConnectToHttpEndpointForTesting?: boolean;
property level
level?: StorageAccessLevel;
property provider
provider?: string;
property region
region?: string;
property track
track?: boolean;
if set to true, automatically sends Storage Events to Amazon Pinpoint
interface StorageProvider
interface StorageProvider {}
method cancel
cancel: (request: Promise<any>) => void;
method configure
configure: (config: object) => object;
method copy
copy: ( src: StorageCopySource, dest: StorageCopyDestination, config?: any) => Promise<any>;
method get
get: (key: string, options?: any) => Promise<string | Object>;
method getCategory
getCategory: () => string;
method getProviderName
getProviderName: () => string;
method list
list: (path: any, options?: any) => Promise<any>;
method put
put: (key: string, object: any, options?: any) => Promise<Object> | UploadTask;
method remove
remove: (key: string, options?: any) => Promise<any>;
interface StorageProviderWithCopy
interface StorageProviderWithCopy extends StorageProvider {}
method copy
copy: ( src: StorageCopySource, dest: StorageCopyDestination, config?: any) => Promise<any>;
interface UploadTask
interface UploadTask {}
property isInProgress
isInProgress: boolean;
property percent
percent: number;
method pause
pause: () => any;
method resume
resume: () => any;
Type Aliases
type CommonStorageOptions
type CommonStorageOptions = Omit< StorageOptions, | 'credentials' | 'region' | 'bucket' | 'dangerouslyConnectToHttpEndpointForTesting'>;
type CustomPrefix
type CustomPrefix = { [key in StorageAccessLevel]?: string;};
type PutResult
type PutResult = { key: string;};
type ResumableUploadConfig
type ResumableUploadConfig = { resumable: true; progressCallback?: (progress: UploadTaskProgressEvent) => any; completeCallback?: (event: UploadTaskCompleteEvent) => any; errorCallback?: (err: any) => any;};
type S3ClientOptions
type S3ClientOptions = StorageOptions & { credentials: ICredentials;} & S3ProviderListConfig;
type S3CopyDestination
type S3CopyDestination = Omit<S3CopyTarget, 'identityId'>;
type S3CopySource
type S3CopySource = S3CopyTarget;
type S3ProviderCopyConfig
type S3ProviderCopyConfig = Omit<CommonStorageOptions, 'level'> & { provider?: 'AWSS3'; bucket?: CopyObjectRequest['Bucket']; cacheControl?: CopyObjectRequest['CacheControl']; contentDisposition?: CopyObjectRequest['ContentDisposition']; contentLanguage?: CopyObjectRequest['ContentLanguage']; contentType?: CopyObjectRequest['ContentType']; expires?: CopyObjectRequest['Expires']; tagging?: CopyObjectRequest['Tagging']; acl?: CopyObjectRequest['ACL']; metadata?: CopyObjectRequest['Metadata']; serverSideEncryption?: CopyObjectRequest['ServerSideEncryption']; SSECustomerAlgorithm?: CopyObjectRequest['SSECustomerAlgorithm']; SSECustomerKey?: CopyObjectRequest['SSECustomerKey']; SSECustomerKeyMD5?: CopyObjectRequest['SSECustomerKeyMD5']; SSEKMSKeyId?: CopyObjectRequest['SSEKMSKeyId'];};
type S3ProviderCopyOutput
type S3ProviderCopyOutput = { key: string;};
type S3ProviderGetConfig
type S3ProviderGetConfig = CommonStorageOptions & { download?: boolean; track?: boolean; expires?: number; provider?: 'AWSS3'; identityId?: string; progressCallback?: (progress: any) => any; cacheControl?: GetObjectRequest['ResponseCacheControl']; contentDisposition?: GetObjectRequest['ResponseContentDisposition']; contentEncoding?: GetObjectRequest['ResponseContentEncoding']; contentLanguage?: GetObjectRequest['ResponseContentLanguage']; contentType?: GetObjectRequest['ResponseContentType']; SSECustomerAlgorithm?: GetObjectRequest['SSECustomerAlgorithm']; SSECustomerKey?: GetObjectRequest['SSECustomerKey']; SSECustomerKeyMD5?: GetObjectRequest['SSECustomerKeyMD5'];};
type S3ProviderGetOuput
type S3ProviderGetOuput<T> = T extends { download: true;} ? GetObjectCommandOutput : string;
type S3ProviderListConfig
type S3ProviderListConfig = CommonStorageOptions & { bucket?: string; pageSize?: number | 'ALL'; provider?: 'AWSS3'; identityId?: string; nextToken?: string;};
type S3ProviderListOutput
type S3ProviderListOutput = { results: S3ProviderListOutputItem[]; nextToken?: string; hasNextToken: boolean;};
type S3ProviderPutConfig
type S3ProviderPutConfig = CommonStorageOptions & (_S3ProviderPutConfig | (_S3ProviderPutConfig & ResumableUploadConfig));
type S3ProviderPutOutput
type S3ProviderPutOutput<T> = T extends { resumable: true;} ? UploadTask : Promise<PutResult>;
type S3ProviderRemoveConfig
type S3ProviderRemoveConfig = CommonStorageOptions & { bucket?: string; provider?: 'AWSS3';};
type S3ProviderRemoveOutput
type S3ProviderRemoveOutput = DeleteObjectCommandOutput;
type StorageAccessLevel
type StorageAccessLevel = 'public' | 'protected' | 'private';
type StorageCopyConfig
type StorageCopyConfig<T extends Record<string, any>> = T extends StorageProviderWithCopy ? StorageOperationConfig<T, 'copy'> : StorageOperationConfigMap< StorageOperationConfig<AWSS3Provider, 'copy'>, T >;
type StorageCopyDestination
type StorageCopyDestination = Omit<StorageCopyTarget, 'identityId'>;
type StorageCopyOutput
type StorageCopyOutput<T> = PickProviderOutput< Promise<S3ProviderCopyOutput>, T, 'copy'>;
type StorageCopySource
type StorageCopySource = StorageCopyTarget;
type StorageCopyTarget
type StorageCopyTarget = { key: string; level?: string; identityId?: string;};
type StorageGetConfig
type StorageGetConfig<T extends Record<string, any>> = T extends StorageProvider ? StorageOperationConfig<T, 'get'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'get'>, T>;
type StorageGetOutput
type StorageGetOutput<T extends StorageProvider | Record<string, any>> = PickProviderOutput<Promise<S3ProviderGetOuput<T>>, T, 'get'>;
type StorageListConfig
type StorageListConfig<T extends Record<string, any>> = T extends StorageProvider ? StorageOperationConfig<T, 'list'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'list'>, T>;
type StorageListOutput
type StorageListOutput<T> = PickProviderOutput< Promise<S3ProviderListOutput>, T, 'list'>;
type StorageOperationConfigMap
type StorageOperationConfigMap<Default, T extends Record<string, any>> = T extends { provider: string;} ? T extends { provider: 'AWSS3'; } ? Default : T & { provider: string; } : Default;
Utility type to allow custom provider to use any config keys, if provider is set to AWSS3 then it should use AWSS3Provider's config.
type StorageProviderApi
type StorageProviderApi = 'copy' | 'get' | 'put' | 'remove' | 'list';
type StoragePutConfig
type StoragePutConfig<T extends Record<string, any>> = T extends StorageProvider ? StorageOperationConfig<T, 'put'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'put'>, T>;
type StoragePutOutput
type StoragePutOutput<T> = PickProviderOutput<S3ProviderPutOutput<T>, T, 'put'>;
type StorageRemoveConfig
type StorageRemoveConfig<T extends Record<string, any>> = T extends StorageProvider ? StorageOperationConfig<T, 'remove'> : StorageOperationConfigMap<StorageOperationConfig<AWSS3Provider, 'remove'>, T>;
type StorageRemoveOutput
type StorageRemoveOutput<T> = PickProviderOutput< Promise<S3ProviderRemoveOutput>, T, 'remove'>;
Package Files (6)
Dependencies (8)
Dev Dependencies (1)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@aws-amplify/storage
.
- Markdown[](https://www.jsdocs.io/package/@aws-amplify/storage)
- HTML<a href="https://www.jsdocs.io/package/@aws-amplify/storage"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4419 ms. - Missing or incorrect documentation? Open an issue for this package.