By Simon Boddy
I’m getting started with Spaces. I’m successfully uploading images from a node backend with s3client and a PutObjectCommand. PutObjectCommand requires a Bucket argument, and it works when I put projectName.bucketName. To my surprise (and distaste), this argument is prepended to the Key, and so finds itself in the URL of the uploaded image. Why is this, and can I turn it off?
This is my upload command…
const command = new PutObjectCommand({
Bucket: "simplyfirst.simplyfirst",
Key,
Body: arr,
ACL: "public-read",
ContentType: contentType
});
try {
const response = await s3Client.send(command);
console.log(response);
return NextResponse.json({newFilename:filename})
} catch (err) {
console.error(err);
return new NextResponse("Error", { status: 500 })
}
…which gives me this in Spaces…

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!
Hi there,
Is your Bucket name actually simplyfirst.simplyfirst? If so, I believe that the dot in the name might be causing an issue here.
Usually having a dot in your Bucket name is not very recommended as it can break the FQDN of the spaces endpoint.
I could suggest trying with a bucket name which does not contain a dot.
If this is not the case, the Bucket name should not be included in the Key parameter. Instead, use only the path inside the bucket. This way, your uploaded objects will not include projectName.bucketName in their paths. I could suggest adding some console log statements to see if this is actually the case.
If none of those help, feel free to share your client definition as well and I will be happy to try and set this up on my end to further test it.
Best,
Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.