Report this

What is the reason for this report?

How to config aws sdk js to use the getObject function through Spaces CDN?

Posted on May 9, 2019

I’m doing a Image Proxy Server and the problem is, some requests take a long time, more than 30s.

How I can improve it to get the objects more quickly?

Maybe the problem is because the requests are not going through the CDN.

My aws sdk js config is:

	accessKeyId: '',
	secretAccessKey: '',
	bucket: 'bucketname',
	endPoint: 'ams3.digitaloceanspaces.com',
	region: 'ams3'

and this function to get the object from Spaces:

	getFile: function(res, file) {
		return new Promise((resolve, reject) => {
			s3.getObject({ Bucket: 'bucketname', Key: file }, (err, data) => {
				//console.log(res, err, data);
				if (!err) {
					return resolve(data);
				} else {
					return reject(err, res);
				}
			});
		}).catch((err) => {
			console.log('Error:', err.statusCode);
		});
	},


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!

The developer cloud

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

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.