我尝试使用AWS C ++ SDK将文件上传到S3。文件传输得很好,但内容类型是"二进制/八位字节流"而不是" text / html"。当我在S3控制台中查看该文件时。有一个" x-amz-meta-content-type"类型记录的类型" text / html"。如何设置我要上传的文件的实际内容类型?
int main (int, char**)
{
Aws::SDKOptions options;
Aws::InitAPI (options);
client = new Aws::S3::S3Client;
Aws::S3::Model::PutObjectRequest request;
request.SetBucket ("mywebsite.notreal.net");
request.SetKey ("index.html");
request.SetACL (Aws::S3::Model::ObjectCannedACL::public_read);
request.SetContentEncoding ("UTF-8");
request.AddMetadata ("Content-Type", "text/html");
auto inputData = Aws::MakeShared<Aws::FStream> ("PutObjectInputStream", "index.html", std::ios_base::in | std::ios_base::ate);
request.SetContentLength (inputData-> tellg ());
request.SetBody (inputData);
auto result = client-> PutObject (request);
return result.IsSuccess () ? 0 : 1;
}
v