Page updated Nov 9, 2023

Get file properties

You can get file properties and metadata without downloading the file using Storage.getProperties API

async function getFileProperties() { try { const result = await Storage.getProperties('key'); console.log('File Properties ', result); } catch (error) { console.log('Error ', error); } }
1async function getFileProperties() {
2 try {
3 const result = await Storage.getProperties('key');
4 console.log('File Properties ', result);
5 } catch (error) {
6 console.log('Error ', error);
7 }
8}

The format of the response will look similar to the below example

{ contentType: "image/jpeg", contentLength: 6873, eTag: "\"56b32cf4779ff6ca3ba3f2d455fa56a7\"", lastModified: Wed Apr 19 2023 14:20:55 GMT-0700 (Pacific Daylight Time) {}, metadata: { owner : 'aws'} }
1{
2 contentType: "image/jpeg",
3 contentLength: 6873,
4 eTag: "\"56b32cf4779ff6ca3ba3f2d455fa56a7\"",
5 lastModified: Wed Apr 19 2023 14:20:55 GMT-0700 (Pacific Daylight Time) {},
6 metadata: { owner : 'aws'}
7}