Golang - Spaces - noSuchBucket Error for copyObject bucket while putObject with the same bucket works

Posted June 21, 2021 260 views
GoDigitalOcean Spaces


I am trying to make a copy of a file in Spaces

If putting in a new file with

bucket := "someBucket"

object := s3.PutObjectInput{
    Bucket:      aws.String(bucket),
    Key:         aws.String(key),

it works, but if copying

bucket := "someBucket"

cpObj := s3.CopyObjectInput{
        Bucket:     aws.String(bucket),
        CopySource: aws.String(fromPath),
        Key:        aws.String(toPath),

_, err := cl.CopyObject(&cpObj)
log.Println("Error", err)

it logs:

Error NoSuchBucket

It does not make any sense to me. Any help appreciated. :)


1 comment
  • Hi nicmila,

    the same is happening for me with node.js and @aws-sdk/client-s3@3.23.0. Whenever I call copyObject the same way you did, the client errors out with NoSuchBucket even though I use the same bucket name for other functions like putObject. This seems to be a bug/missing feature on DigitalOcean’s end then… Were you able to solve your problem?

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.

Submit an Answer
2 answers

I have programmed around it in my code. I have not found a way how to persuade CopyObjectInput to work as intended.