Question

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

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);
		});
	},
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!