使用S3 AmazonS3Client listObjects preFIX通配符?通配符、AmazonS3Client、preFIX、listObjects

2023-09-11 09:50:05 作者:醉榻天下

请问AWS S3 A​​mazonS3Client.listObjects(的http://文档。 aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html )支持通配符? 例如,可以将一个做到以下几点:

  ListObjectsRequest listObjectsRequest =新ListObjectsRequest()。
withBucketName(富)。
其中preFIX(* / DT = 2013年3月28日/ *)。
withDelimiter(/);
 

解决方案

没有,你不能。事实上, * 是在S3键名有效的字符。例如,像一键 /foo/b*ar/dt=2013-03-28/abc.xml 是有效的。照片 你要么需要根据共同preFIX重新组织你的钥匙或遍历所有。

PS:这取决于你的使用情况,这是可能的,你可以使用 标记

亚马逊s3的使用方法 使用Amazon S3 –第一部分

Does the AWS S3 AmazonS3Client.listObjects (http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/index.html) support wildcard? for example, can one do the following:

ListObjectsRequest listObjectsRequest = new ListObjectsRequest().
withBucketName("foo").
withPrefix("*/dt=2013-03-28/*").
withDelimiter("/");

解决方案

No, you cannot. In fact, * is a valid character in a key name in S3. For example, a key like /foo/b*ar/dt=2013-03-28/abc.xml is valid. You will either need to reorganize your keys according to a common prefix or iterate over them all.

PS: depending on your use case, it is possible that you can use a marker.