Remove files
Delete stored data from the storage bucket. To remove a file, you need to provide the fully specified path
.
Files can only be deleted for the current user. Deletion capabilities do not extend to files associated with other users.
1import { remove } from 'aws-amplify/storage';2
3try {4 await remove({ 5 path: 'public/album/2024/1.jpg',6 // Alternatively, path: ({identityId}) => `protected/${identityId}/album/2024/1.jpg`7 });8} catch (error) {9 console.log('Error ', error);10}
1import { remove } from 'aws-amplify/storage';2
3try {4 await remove({ 5 key: 'album/2024/1.jpg', 6 options: { 7 accessLevel: 'guest' // defaults to `guest` but can be 'private' | 'protected' | 'guest'8 } 9 });10} catch (error) {11 console.log('Error ', error);12}