如何设置缓存控制使用写S3Object什么时候? [英] How can I set the Cache-Control when using Write-S3Object?

查看:415
本文介绍了如何设置缓存控制使用写S3Object什么时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Windows PowerShell的AWS,我已经试过如下:

I am using Windows Powershell for AWS and I have tried the following:

Write-S3Object 
   -BucketName 'user-ab-staging' 
   -KeyPrefix 'content/css' 
   -Folder 'content/css' 
   -SearchPattern '*.css' 
   -Metadata @{"Cache-Control" = "Value"}
   -CannedACLName PublicRead

它给了我一个很奇怪的错误,只尝试加载一个CSS文件:

It gives me a very strange error and only tries to load one css file:

Uploaded 1 object(s) to bucket 'user-ab-staging' from 'C:\g\ab-user\WebUserApp\content\css' with keyprefix
 'content/css'
Write-S3Object :
At line:1 char:1
+ Write-S3Object `
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Objec
   t], InvalidOperationException
    + FullyQualifiedErrorId : Amazon.S3.AmazonS3Exception,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet

谁能帮忙告诉我什么是不对的,我怎么可以设置缓存数据的对象的时候,我的使用写S3Object PowerShell的扩展AWS

推荐答案

我设置了​​一些测试文件夹,在本地和S3,可以准确地复制了这个问题。

I set up some test folders locally and on S3 and can replicate this issue exactly.

在一些挖/试验......它涉及到 CannedACLName 参数。这些文件删除了参数,当成功上传。

After some digging/experimenting... it relates to the CannedACLName parameter. The files upload successfully when removing that parameter.

文档说,正确的选项使用 PublicRead ,但正确的选择实际上是公共阅读。做出这样的转变之后,我就能够成功写入的所有对象指定的文件夹中。

This documentation says that the correct option to use is PublicRead, but the correct option is actually public-read. After making that change, I was able to successfully write all objects in the specified folder.

您更新code是这样的:

Your updated code would look like this:

Write-S3Object 
   -BucketName 'user-ab-staging' 
   -KeyPrefix 'content/css' 
   -Folder 'content/css' 
   -SearchPattern '*.css' 
   -Metadata @{"Cache-Control" = "Value"}
   -CannedACLName public-read

如果您需要使用的任何其他访问控制列表选项,在未来,我会建议从的此列表ACL的文档,而不是研究。我测试过的几个有可用的选项和他们都工作过。

If you need to use any of the other ACL options in the future, I would recommend trying from this list in the ACL documentation instead. I've tested a few of the options available there and they've all worked.

这篇关于如何设置缓存控制使用写S3Object什么时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆