CloudfFont GetObjectRequest等效于从S3下载文件

时间:2017-10-04 23:10:57

标签: c# amazon-web-services amazon-s3 amazon-cloudfront

我正在修改一个使用私有CloudFront而不是直接使用S3的应用程序。

我已经能够创建签名的URL并根据需要填充图片框。

我无法找到与GetObjectRequest相同的CloudFront ......

for (int num = 1; num < 16; num++)
{

    GetObjectRequest request = new GetObjectRequest
    {
        BucketName = ContainerName,
        Key = tempDownload + @"/" + num + ".jpg"
    };

    try
    {
        //Issue request and remember to dispose of the response
        using (GetObjectResponse response = s3Client.GetObject(request))
        {
          string dest = Path.Combine(newFileFolder, tempDownload + num + ".jpg");
            if (!File.Exists(dest))
            {
                response.WriteResponseStreamToFile(dest);
            }
        }
    }
}

我正在尝试通过Cloudfront将文件下载到应用程序用户的硬盘上。

1 个答案:

答案 0 :(得分:2)

CloudFront没有等效于GetObject的内容。 CloudFront旨在通过HTTP / HTTPS协议提取数据。

如果您要下载到用户计算机的文件是公开的,那么您只需通过CloudFront发行版http / https URL访问它们。

如果您要下载的文件是私有的,那么您需要将原始访问标识设置为Serve Private Content或通过CloudFront分发http / https URL使用Pre-signed URLs