duancenxie2233 2017-04-07 17:55
浏览 1066
已采纳

AWS S3 ListObjectsV2返回MaxKeys仅设置为10的完整文件列表

I'm trying to implement S3 client in PHP that lists only 10 files at a time through pagination feature. To accomplish this, as per the API doc, i'm making following call:

$result = $this->s3->getPaginator('ListObjectsV2', [
            'Bucket'       => 'my_s3_bucket_name',
            'Delimiter'    => '/',
            'MaxKeys'      => 10,
            'StartAfter'   => urlencode($_SESSION['prev_key'])
        ]);

and using JMESPath expression to extract the subset of data that i need to display. The above seems to "work" but it seems to retrieve JSON set with child subsets containing 10 files each. In other words, if i had 26 files stored on my bucket, i'd get all 26 files in 3 subsets of array--all in single request. Obviously, S3 has been around long time and i'm sure there's a best practice for what i'm trying to achieve. However, i've searched for past few days to no avail. If anyone could point me in the right direction pls...

  • 写回答

1条回答 默认 最新

  • dongyanghan0556 2017-04-09 04:31
    关注

    The point of the paginator is to get everything -- doing the pagination necessary to fetch the full result.

    And as you're using it, it would be done in sets of 10.

    If you want to make a specific request, like you show here, don't use the paginator, just use ListObjectsV2 directly.

    Also, I doubt that it's appropriate or necessary to urlencode() the previous key. The SDK should do it for you if needed.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 专家修改了标签 8月18日

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧