AWSSDKS3ListObjectsV2Async返回空的对象列表。
创始人
2024-09-27 04:30:31
0

如果您使用的是异步版本的 AWS SDK for .NET S3 ListObjectsV2Async,返回空对象列表可能是由于以下原因引起的:

  1. 桶名称或前缀不正确,导致返回的对象列表为空。

  2. 您没有足够的权限来列出存储桶的对象。

您可以使用以下代码修改您的 AWSSDK S3 ListObjectsV2Async 实现,以确保返回的对象列表正确:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;

namespace S3ListAsync
{
    class Program
    {
        static async Task Main()
        {
            // Replace accessKeyId, secretAccessKey and region with your own values.
            var credentials = new Amazon.Runtime.BasicAWSCredentials("accessKeyId", "secretAccessKey");
            var config = new AmazonS3Config { RegionEndpoint = RegionEndpoint.USWest2 };
            var client = new AmazonS3Client(credentials, config);

            // Replace bucketName and prefix with your own values.
            var request = new ListObjectsV2Request
            {
                BucketName = "bucketName",
                Prefix = "prefix"
            };

            ListObjectsV2Response response;
            var objects = new List();

            do
            {
                response = await client.ListObjectsV2Async(request);

                objects.AddRange(response.S3Objects);

                request.ContinuationToken = response.NextContinuationToken;
            } while (response.IsTruncated);

            if (objects.Count > 0)
            {
                Console.WriteLine("Objects:");
                foreach (var s3Object in objects)
                {
                    Console.WriteLine(s3Object.Key);
                }
            }
            else
            {
                Console.WriteLine("No objects found.");
            }
        }
    }
}

上面的代码使用 AWS SDK for .NET Aync 的方式列出指定存储桶中的对象列表。确保替换所有示例代码中的占位符,例如“accessKeyId”、“secretAccessKey”、“region”、“bucketName”和“prefix”。如果您的代码仍然返回空

相关内容

热门资讯

透视关于!hhpoker脚本下... 透视关于!hhpoker脚本下载(透视)wepoker怎么买辅助,教程方式(有挂方式)-哔哩哔哩1、...
透视透视!wepoker透视脚... 您好,wepoker亲友圈有用吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【48527505...
透视开挂!wepoker透视脚... 透视开挂!wepoker透视脚本是什么(透视)wepoker辅助器,教程方案(真的有挂)-哔哩哔哩1...
透视曝光!pokemmo免费脚... 透视曝光!pokemmo免费脚本(透视)wepoker辅助是真的假的,教程模块(有挂助手)-哔哩哔哩...
透视推荐!hhpoker脚本(... 透视推荐!hhpoker脚本(透视)wepoker辅助是真的吗,教程技法(有挂秘笈)-哔哩哔哩;小薇...
透视解谜!wpk透视工作室(透... 透视解谜!wpk透视工作室(透视)德州局透视脚本下载安装最新版本,教程秘籍(有挂秘笈)-哔哩哔哩1、...
透视科普!hh poker插件... 透视科普!hh poker插件下载(透视)安装不了wepoker,教程大纲(有挂方略)-哔哩哔哩1、...
透视曝光!wepoker私人辅... 透视曝光!wepoker私人辅助器(透视)哈糖大菠萝攻略,教程烘培(有挂讲解)-哔哩哔哩1、下载好w...
透视曝光!wepoker有辅助... 透视曝光!wepoker有辅助功能吗(透视)pokemmo脚本辅助下载,教程教材(有挂方针)-哔哩哔...
透视解谜!约局吧透视脚本(透视... 透视解谜!约局吧透视脚本(透视)aapoker俱乐部靠谱吗,教程模板(有挂透视)-哔哩哔哩进入游戏-...