简体   繁体   English

如何使用 .NET AWS SDK 在从 AWS S3 检索时过滤、模式匹配文件?

[英]How To Filter, Pattern-Match Files on Retrieval from AWS S3 using .NET AWS SDK?

When using the ListObjects request (.NET AWS SDK), is there a way to only list files where the key matches a given pattern?使用ListObjects请求(.NET AWS SDK)时,有没有办法只列出键与给定模式匹配的文件? Or, more broadly, is there a way to query files from S3 based on their key using any request type from the .NET AWS SDK?或者,更广泛地说,有没有一种方法可以使用 .NET AWS 开发工具包中的任何请求类型根据密钥从S3查询文件?

I'm aware of the --query param, available on AWS CLI , but I'm not able to find an equivalent method on .NET.我知道AWS CLI 上可用--query参数,但我无法在 .NET 上找到等效的方法。

I'm looking for a way to run the query server-side so that ListObjects returns a pattern-matching set of keys.我正在寻找一种运行查询服务器端的方法,以便ListObjects返回一组模式匹配的键。 I'd like to avoid retrieving all files and then filter them.我想避免检索所有文件and then过滤它们。

The AWS CLI uses JMESPath for query expressions. AWS CLI 将JMESPath用于查询表达式。 There is a .NET port called JmesPath.NET that is compatible with the same API and is well-maintained.有一个名为JmesPath.NET的 .NET 端口,它与相同的 API 兼容并且维护良好。 You could use the SDK to retrieve the result set, and then filter it with JmesPath.NET expressions.您可以使用 SDK 来检索结果集,然后使用 JmesPath.NET 表达式对其进行过滤。 It's available as a NuGet package too.它也可以作为NuGet 包使用

The --query param on the CLI filters the result set on output, similar to what would happen with JmesPath.NET. CLI 上的--query参数过滤输出的结果集,类似于 JmesPath.NET 会发生的情况。 It doesn't affect what the API call returns.它不会影响 API 调用返回的内容。 The only request parameters available to reduce the result set are prefix and delimiter , which group things logically like a folder structure does in a file storage engine.可用于减少结果集的唯一请求参数是prefixdelimiter ,它们在逻辑上对事物进行分组,就像文件存储引擎中的文件夹结构一样。 Unless your use case can be handled by those parameters, you're stuck with filtering on the output side.除非您的用例可以由这些参数处理,否则您将不得不在输出端进行过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用AWS SDK for .NET或REST API从Amazon S3检索包含图像和样式表的HTML文件 - Retrieving HTML files with images and style sheets from Amazon S3 using AWS SDK for .NET or REST API 使用AWS S3 SDK for .NET从Amazon S3下载并行批处理文件 - Parallel batch file download from Amazon S3 using AWS S3 SDK for .NET 使用AWS开发工具包将文件上传到.NET Core中的S3 - Using AWS SDK to upload file to S3 in .NET Core 在.net上将AWS开发工具包与localstack一起使用(TransferUtility / S3-设置终端节点) - Using AWS SDK on .net with localstack (TransferUtility/S3 - setting endpoint) 有没有办法使用适用于 .NET 的 AWS SDK 将对象从 S3 存储桶下载到文件目标? - Is there a way to download an object from S3 bucket to a file destination using AWS SDK for .NET? 如何仅使用c#从Amazon s3下载文件(不使用AWS开发工具包) - How to download file from amazon s3 using only c#(Without using AWS SDK) 如何使用 C#/.Net 从 AWS S3 下载文件列表到我的设备? - How to download a list of files from AWS S3 with C# / .Net to my device? AWS .NET SDK直接上传到S3-预签名URL - AWS .NET SDK Direct Upload to S3 - Pre Signed URL 使用AWS .NET SDK将文件上载到S3存储桶时,任务被取消了异常? - Task was cancelled exception when uploading file to S3 bucket using AWS .NET SDK? 使用AWS SDK进行S3上载的带宽限制 - Bandwidth throttling for S3 upload using AWS SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM