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”。如果您的代码仍然返回空

相关内容

热门资讯

wepoke是真的有挂!云扑克... wepoke是真的有挂!云扑克辅助器怎么卖(透视)真是真的有挂(详细辅助插件教程)1、构建自己的微扑...
透视工具!WePoKe透明挂,... 透视工具!WePoKe透明挂,wepoke调控参数,详细透视插件教程透视工具!WePoKe透明挂,w...
微扑克德州专用辅助器!wepo... 您好,微扑克德州专用辅助器这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩...
辅助透视!wepoke ai辅... 辅助透视!wepoke ai辅助,wepoke有挂吗网上靠谱吗,详细透视透明挂教程;1)wepoke...
微扑克有辅助挂!fishpok... 微扑克有辅助挂!fishpoker扑克辅助(透视)起初有挂(详细辅助攻略方法)1)微扑克有辅助挂辅助...
透视规律!wepok软件透明挂... 透视规律!wepok软件透明挂,we poke软件免费版,详细透视揭秘教程;1、透视规律!wepok...
德州之星辅助!wepoke有假... 德州之星辅助!wepoke有假吗(透视)其实存在有挂(详细辅助揭秘攻略);无聊就玩这款德州之星辅助真...
透视好友房!wepok软件透明... 透视好友房!wepok软件透明挂,wepower伙牌,详细透视科技教程1、wepok软件透明挂系统规...
wpk有辅助挂!wpk线上实战... 1、wpk有辅助挂!wpk线上实战(透视)切实真的是有挂(详细辅助总结教程);代表性(透视辅助软件透...
透视挂!wepokeai机器人... 透视挂!wepokeai机器人,wopoker有没有外挂,详细透视玩家教程小薇(透视辅助)致您一封信...