예제 #1
0
        public async Task <IActionResult> Login()
        {
            S3BuketsList buketsList = new S3BuketsList();

            // var options = Configuration.GetAWSOptions();

            // AmazonS3Config config = new AmazonS3Config();

            // using (var client = new AmazonS3Client(Amazon.RegionEndpoint.APNortheast1))
            // {
            //     var a = 0;
            //     // var response = client.ListBuckets();
            // }
            // var b = 1;

            CredentialProfile basicProfile;
            AWSCredentials    awsCredentials;
            var sharedFile = new SharedCredentialsFile();

            if (sharedFile.TryGetProfile("SimCheckAppProfile", out basicProfile) &&
                AWSCredentialsFactory.TryGetAWSCredentials(basicProfile, sharedFile, out awsCredentials))
            {
                using (var client = new AmazonS3Client(awsCredentials, Amazon.RegionEndpoint.APNortheast1))
                {
                    Amazon.S3.Model.ListBucketsResponse response = await client.ListBucketsAsync();

                    buketsList.ListBuckets = response;
                }
            }

            return(View("Index", buketsList));
        }
 public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) 
 {   
     ListBucketsResponse response = new ListBucketsResponse();
     
     while (context.Read())
     {
         if (context.IsStartElement)
         {                    
             UnmarshallResult(context,response);                        
             continue;
         }
     }
          
                 
     return response;
 }
        private static void UnmarshallResult(XmlUnmarshallerContext context,ListBucketsResponse response)
        {
            
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            
            if (context.IsStartOfDocument) 
               targetDepth += 2;
            
            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Bucket", targetDepth + 1))
                    {
                        response.Buckets.Add(BucketUnmarshaller.Instance.Unmarshall(context));
                            
                        continue;
                    }
                    if (context.TestExpression("Owner", targetDepth))
                    {
                        response.Owner = OwnerUnmarshaller.Instance.Unmarshall(context);
                            
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }
                            


            return;
        }