Copy files
You can copy an existing file to a different path within the storage bucket using the copy API.
The copy
method duplicates an existing file to a designated path and returns an object {path: 'destPath'}
upon successful completion.
import { copy } from 'aws-amplify/storage';
const copyFile = async () => { try { const response = await copy({ source: { path: 'album/2024/1.jpg', // Alternatively, path: ({identityId}) => `album/{identityId}/1.jpg` }, destination: { path: 'shared/2024/1.jpg', // Alternatively, path: ({identityId}) => `shared/{identityId}/1.jpg` }, }); } catch (error) { console.error('Error', err); }};
More copy
options
Option | Type | Description | Reference Links |
---|---|---|---|
useAccelerateEndpoint | boolean | Whether to use accelerate endpoint. | Transfer Acceleration |