Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
aws java sdk未返回所有文件夹_Java_Amazon Web Services_Amazon S3 - Fatal编程技术网

aws java sdk未返回所有文件夹

aws java sdk未返回所有文件夹,java,amazon-web-services,amazon-s3,Java,Amazon Web Services,Amazon S3,运行 它正在返回我期望的所有文件。我已正确设置权限和凭据。然后我编写了一些java代码: $ aws s3 ls s3://mybucket/myfolder/subfolder/monitor/ 代码在mybucket/myfolder/subfolder中打印内容,但在monitor中没有任何内容(并且缺少其他子目录)。我没有看到任何错误。我如何诊断为什么看不到更多的文件。我显然有权限访问文件夹,并且凭据正在工作。任何建议都是有益的。谢谢 只是一个猜测,但可能所有的结果都不符合一个回答。查

运行

它正在返回我期望的所有文件。我已正确设置权限和凭据。然后我编写了一些java代码:

$ aws s3 ls s3://mybucket/myfolder/subfolder/monitor/

代码在mybucket/myfolder/subfolder中打印内容,但在monitor中没有任何内容(并且缺少其他子目录)。我没有看到任何错误。我如何诊断为什么看不到更多的文件。我显然有权限访问文件夹,并且凭据正在工作。任何建议都是有益的。谢谢

只是一个猜测,但可能所有的结果都不符合一个回答。查看是否为NOTNULL。

您必须提供详细信息,显示命令行和程序的输出,至少足以显示其行为不符合预期的差异。
public class S3Sample {
    public static void main(String[] args) throws IOException {
    AWSCredentials credentials = null;
    try {
        credentials = new ProfileCredentialsProvider().getCredentials();
    } catch (Exception e) {
        throw new AmazonClientException(
                "Cannot load the credentials from the credential profiles file. " +
                "Please make sure that your credentials file is at the correct " +
                "location (~/.aws/credentials), and is in valid format.",
                e);
    }

    AmazonS3 s3 = new AmazonS3Client(credentials);
    try {

        ObjectListing objectListing = s3.listObjects(new ListObjectsRequest()
                    .withBucketName("mybucket"));
                        for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries()) {
                System.out.println(objectSummary.getKey());
                        }

    } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it "
                + "to Amazon S3, but was rejected with an error response for some reason.");
        System.out.println("Error Message:    " + ase.getMessage());
        System.out.println("HTTP Status Code: " + ase.getStatusCode());
        System.out.println("AWS Error Code:   " + ase.getErrorCode());
        System.out.println("Error Type:       " + ase.getErrorType());
        System.out.println("Request ID:       " + ase.getRequestId());
    } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered "
                + "a serious internal problem while trying to communicate with S3, "
                + "such as not being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
    }

}