Amazon.S3.AmazonS3Client.ListObjectsV2Async C# (CSharp) Method

ListObjectsV2Async() public method

Initiates the asynchronous execution of the ListObjectsV2 operation.
public ListObjectsV2Async ( ListObjectsV2Request request, System cancellationToken = default(CancellationToken) ) : Task
request ListObjectsV2Request Container for the necessary parameters to execute the ListObjectsV2 operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task<ListObjectsV2Response> ListObjectsV2Async(ListObjectsV2Request request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListObjectsV2RequestMarshaller();
            var unmarshaller = ListObjectsV2ResponseUnmarshaller.Instance;

            return InvokeAsync<ListObjectsV2Request,ListObjectsV2Response>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Same methods

AmazonS3Client::ListObjectsV2Async ( ListObjectsV2Request request, ListObjectsV2Response>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

        /// <summary>
        /// https://docs.aws.amazon.com/AmazonS3/latest/dev/ListingObjectKeysUsingNetSDK.html
        /// </summary>
        /// <returns></returns>
        async Task ListObjectsAsync()
        {
            //List Objects in the Bucket
            ListObjectsV2Request listRequest = new ListObjectsV2Request
            {
                BucketName = awsBucket,
                MaxKeys    = 3
            };
            /// Can also limit Searches with Prefix = searchKeyPrefix
            ///MaxKeys=3 for testing

            ListObjectsV2Response listResponse;

            do
            {
                LOGINFO("OnTask, ListObjectsV2Async: " + listRequest.ToString());
                listResponse = await s3Client.ListObjectsV2Async(listRequest);

                //Process the response
                foreach (S3Object entry in listResponse.S3Objects)
                {
                    LOGINFO("Processing Object Key=" + entry.Key + ", Size=" + entry.Size);
                    var fileName = archivePath + "\\" + entry.Key;
                    ReadObjectDataAsync(entry.Key, fileName).Wait();

                    //Send the local Filename to the Business Service
                    BusinessHost.ProcessInput(fileName);

                    //Now delete the Entry in S3
                    DeleteObjectNonVersionedBucketAsync(entry.Key).Wait();
                }
            } while (listResponse.IsTruncated);
        }
All Usage Examples Of Amazon.S3.AmazonS3Client::ListObjectsV2Async
AmazonS3Client