/// <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); }
public override void OnTask() { Console.Write("\r\n[.NET]...Demo.PEX.InboundAdapter:OnTask() is called"); // 50% chance of calling ProcessInput() if ((new Random()).NextDouble() < 0.5) { SimpleObject request = new SimpleObject("message #" + (++runningCount)); Console.Write("\r\n[.NET]...Demo.PEX.InboundAdapter:OnTask() calls ProcessInput() with " + request.value); string response = (string)BusinessHost.ProcessInput(request); Console.Write("\r\n[.NET]...Demo.PEX.InboundAdapter:OnTask() receives \"" + response + "\""); } return; }
public override void OnTask() { // Check input directory for files and create enumerable containing file paths. IEnumerable <string> folder = Directory.EnumerateFiles(InboundFilePath); // Enumerate over files in the directory. foreach (string file in folder) { // Ignore .keep file string[] SplitFilePath = file.Split(Path.DirectorySeparatorChar); // .keep files are used to retain directory structure in git. // these need to be skipped over so they are not processed by the production. if (SplitFilePath[(SplitFilePath.Length - 1)] == ".keep") { continue; } // Call ProcessInput method of connected business service BusinessHost.ProcessInput(file); } return; }