Remove files
Delete stored data from the storage bucket. To remove a file, you need to provide the key. accessLevel
can be 'guest', 'private', or 'protected', defaulting to 'guest'. Files can only be deleted for the current user. Deletion capabilities do not extend to files associated with other users.
Guest level remove
1import { remove } from 'aws-amplify/storage';2
3try {4 await remove({ key: filename });5} catch (error) {6 console.log('Error ', error);7}
Protected level remove
1import { remove } from 'aws-amplify/storage';2
3try {4 await remove({ key: filename, options: { accessLevel: 'protected' } });5} catch (error) {6 console.log('Error ', error);7}
Private level remove
1import { remove } from 'aws-amplify/storage';2
3try {4 await remove({ key: filename, options: { accessLevel: 'private' } });5} catch (error) {6 console.log('Error ', error);7}