Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
You can access a file’s metadata in DigitalOcean Spaces by using the AWS SDK for S3, as Spaces is S3-compatible. Here’s an example in JavaScript using the AWS SDK for Node.js:
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'nyc3'}); // update to your region
// Create S3 service object with DigitalOcean Spaces endpoint
var s3 = new AWS.S3({
endpoint: 'nyc3.digitaloceanspaces.com', // update to your Spaces endpoint
accessKeyId: 'YOUR_ACCESS_KEY', // replace with your access key
secretAccessKey: 'YOUR_SECRET_KEY' // replace with your secret key
});
var params = {
Bucket: 'your-bucket-name',
Key: 'your-object-key'
};
s3.headObject(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
In this code, s3.headObject(params, ...) is used to retrieve the metadata of an object. The data object in the callback will contain a Metadata field that contains the metadata of the object.
Remember to replace 'YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY', 'your-bucket-name', and 'your-object-key' with your own values. The 'your-object-key' is the file name in the bucket.
Note: AWS SDK uses the us-east-1 region by default. Since DigitalOcean Spaces doesn’t use AWS regions, you can put any string there when configuring the AWS SDK, but it cannot be left blank.
Best,
Bobby