How to Check S3 Object Metadata and File Properties

Object metadata is information about a file held in S3 compatible object storage. It lets you check file size, content type, ETag, last-modified time and other properties without downloading the entire file.

You can get these properties using the AWS CLI and the HeadObject API operation in Cyberin S3 Object Storage.

Step 1: Retrieve Object Metadata

Run the following command:

aws s3api head-object \
  --bucket YOUR_SPACE_NAME \
  --key path/to/your-file.pdf \
  --endpoint-url https://YOUR_REGION.digitaloceanspaces.com

Replace YOUR_SPACE_NAME with your Space name, path/to/your-file.pdf with the actual object key, and YOUR_REGION with your Space's region, such as sgp1.

The command returns the object's available metadata without downloading its contents.

Step 2: Check the File Properties

Review the command output for the following fields:

Property

What it tells you

ContentLength

File size in bytes.

ContentType

The file's declared MIME type, such as image/jpeg or application/pdf.

ETag

An identifier associated with the stored object representation.

LastModified

The date and time the object was last modified.

Metadata

Custom metadata associated with the object, if present.

ContentDisposition

The configured content disposition, which can influence whether a browser displays or downloads the file.

For example, a ContentLength value of 204800 means the file is 200 KiB.

Note: An ETag is not always the MD5 checksum of the complete file, particularly for multipart uploads. Use an appropriate checksum when you need to verify file integrity.

Step 3: Verify the Content-Type and Download Behavior

If a file opens in the browser instead of downloading, inspect the ContentType and ContentDisposition fields.

If either property needs to change, update the object's metadata using an appropriate upload or copy operation. The head-object command only retrieves metadata; it does not modify it.

Additional Resources