public async Task <List <securityAdminRole> > ReadSecurityAdminRoleFromBucket() { List <securityAdminRole> cList = new List <securityAdminRole>(); AmazonS3Client s3Client = GetS3Client(); ListObjectsRequest lor = new ListObjectsRequest() { BucketName = SecurityAdminRoleBucket, }; ListObjectsResponse response1 = await s3Client.ListObjectsAsync(lor); List <S3Object> theObjects = response1.S3Objects; foreach (S3Object s3Obj in theObjects) { GetObjectRequest gor = new GetObjectRequest() { BucketName = SecurityAdminRoleBucket, Key = s3Obj.Key }; GetObjectResponse gorr = await s3Client.GetObjectAsync(gor); StreamReader reader = new StreamReader(gorr.ResponseStream); string text = reader.ReadToEnd(); securityAdminRole g = JsonConvert.DeserializeObject <securityAdminRole>(text); cList.Add(g); } return(cList); }
public async Task <PutObjectResponse> WriteSecurityAdminRoleToBucket(securityAdminRole g) { // Lets check to make sure the BUcket Exists.. otherwise create a new one. Task.Run(() => this.CheckCreateBucketAsync(SecurityAdminRoleBucket)).Wait(); AmazonS3Client s3Client = GetS3Client(); var por = new PutObjectRequest { BucketName = SecurityAdminRoleBucket, Key = g.SecurityAdminkey, ContentBody = JsonConvert.SerializeObject(g) }; por.Metadata.Add("Type", "securityAdminRole"); PutObjectResponse porr = await s3Client.PutObjectAsync(por); return(porr); // System.Diagnostics.Debug.WriteLine("Object written: " + response1.ToString()); }