Get file properties
You can get file properties and metadata without downloading the file using getProperties
API from aws-amplify/storage
1import { getProperties } from 'aws-amplify/storage';2
3try {4 const result = await getProperties({5 key: 'key',6 options: {7 accessLevel: 'guest', // defaults to `guest` but can be 'private' | 'protected' | 'guest'8 targetIdentityId: 'xxxxxxx' // ID of another user, if `accessLevel: protected`9 }10 });11 console.log('File Properties ', result);12} catch (error) {13 console.log('Error ', error);14}
The format of the response will look similar to the below example
1{2 key : "key",3 contentType: "image/jpeg",4 contentLength: 6873,5 eTag: "\"56b32cf4779ff6ca3ba3f2d455fa56a7\"",6 lastModified: Wed Apr 19 2023 14:20:55 GMT-0700 (Pacific Daylight Time) {},7 metadata: { owner : 'aws' }8}