Skip to main content

Metadata

Manage file metadata: content type, size, uploader info, and custom properties.

Get Metadata

const bucket = client.storage.bucket('avatars');

const meta = await bucket.getMetadata('user-1.jpg');
// {
// key: 'user-1.jpg',
// size: 245789,
// contentType: 'image/jpeg',
// etag: '"a1b2c3..."',
// uploadedAt: '2026-03-01T12:00:00.000Z',
// uploadedBy: 'user-id',
// customMetadata: { alt: 'Profile photo' }
// }

FileInfo Type

PropertyTypeDescription
keystringFile path within the bucket
sizenumberFile size in bytes
contentTypestringMIME type
etagstringR2 entity tag (changes on update)
uploadedAtstringISO 8601 upload timestamp
uploadedBystring | nullAuth user ID (auto-set on upload)
customMetadataRecord<string, string>Custom key-value pairs

Update Metadata

const bucket = client.storage.bucket('avatars');

await bucket.updateMetadata('user-1.jpg', {
customMetadata: { alt: 'Updated profile photo', category: 'avatars' },
contentType: 'image/webp', // optional: change content type
});
info

Only customMetadata and contentType can be updated. Other fields (size, etag, uploadedAt, uploadedBy) are managed by the system.

REST API

EndpointMethodDescription
/api/storage/:bucket/:key/metadataGETGet file metadata
/api/storage/:bucket/:key/metadataPATCHUpdate file metadata