使用S3 .NET客户端中的条件开始
我正在与S3 .NET客户端合作,并且我能够得到一个预先签名的URL(我遵循本教程在线)。我想让用户仅将其文件存储在特定路径中(例如,进入'testTest/'文件夹)。
如另一个堆栈Frows 使用:
Conditions=[["starts-with", "$key", "uploads/"]]
我正在使用.NET S3客户端,实际上似乎无法设置此条件。 您有一个想法如何设置“开始”选项?
我尝试使用以下几行中显示的“参数”而没有成功。
< !--language - all: cs-- >
GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
{
BucketName = _BucketName,
Key = key,
Expires = expiryTime,
Verb = HttpVerb.PUT
};
request1.Parameters.Add("Conditions", "[\"starts-with\", \"testtest/\"]"); // <== THIS LINE
I'm working with the S3 .net client and I'm perfectly able to get a presigned url (I followed this tutorial online). I would like to let the user to store their files in a specific path only (for example into the 'testtest/' folder).
As explained also here in another StackFlow thread, is possible to use:
Conditions=[["starts-with", "$key", "uploads/"]]
I'm using the .net S3 client and actually seems that there is no way to set this condition.
Do you have an idea how to set "starts-with" option?
I tried to use the "parameters" as show in the following lines without success.
< !--language - all: cs-- >
GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
{
BucketName = _BucketName,
Key = key,
Expires = expiryTime,
Verb = HttpVerb.PUT
};
request1.Parameters.Add("Conditions", "[\"starts-with\", \"testtest/\"]"); // <== THIS LINE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您有正确的想法,但是您的病情无效。条件实际上是一系列条件,
启动与
需要知道要看什么,因此类似的事情应该有效:这是否实际上有帮助。似乎最好的做法是在上传之前,在每个文件(键)上获取一个签名的URL。
It looks like you had the right idea, but your condition was not valid. Conditions is actually an array of conditions, and
starts-with
needs to know what to look at, so something like this should work:Whether or not this actually helps is somewhat debatable. It seems the best practice is to get a signed URL for each file (key) before uploading against it.