Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 在AWS SDK(golang)中设置内容配置和内容类型无效_Amazon Web Services_Go_Amazon S3_Aws Sdk - Fatal编程技术网

Amazon web services 在AWS SDK(golang)中设置内容配置和内容类型无效

Amazon web services 在AWS SDK(golang)中设置内容配置和内容类型无效,amazon-web-services,go,amazon-s3,aws-sdk,Amazon Web Services,Go,Amazon S3,Aws Sdk,标题说明了其中的大部分。 我有以下代码: copySource := bucket + "/" + sourcePath + "/" + filenameIn destPath := lambdaParams.DestinationPath + "/" + filenameIn copyObjectInput := s3.CopyObjectInput{ CopySource: aws.String(copySour

标题说明了其中的大部分。 我有以下代码:

        copySource := bucket + "/" + sourcePath + "/" + filenameIn
        destPath := lambdaParams.DestinationPath + "/" + filenameIn
        copyObjectInput := s3.CopyObjectInput{
                CopySource: aws.String(copySource),
                Bucket:     aws.String(bucket),
                Key:        aws.String(destPath),
        }

            if filepath.Ext(filenameIn) == ".pdf" {
copyObjectInput.SetContentType("application/pdf").SetContentDisposition("inline; filename=\"" + filenameIn + "\"")
            }

            _, err := svc.CopyObject(&copyObjectInput)
            if err != nil {
                    logErrorAndInformGFS(err, "S3 copy error.", c, log, filenameIn)
                    return err
            }

我正在设置
内容类型
内容配置
,希望复制的对象具有
内容类型
内容配置
中的新值。但是,我可以在AWS中看到复制的文件与原始文件具有相同的元数据。我遗漏了什么?

问题似乎是我需要告诉AWS我想替换元数据。添加以下行最终允许我更改元数据:

copyObjectInput.SetMetadataDirective("REPLACE")

尝试一个指向s3.CopyObjectInput的指针,
CopyObjectInput:=&s3.CopyObjectInput{}
这是一个很好的建议,我甚至不知道它是作为对象而不是引用编译的。但是,修改元数据仍然不够。这就是stackoverflow的意义所在,感谢您花时间记录这个@SearcherMain