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 async Task <IActionResult> DownloadFile() { S3BuketsList buketsList = new S3BuketsList(); 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)) { GetObjectRequest getObjectRequest = new GetObjectRequest(); getObjectRequest.BucketName = "devpiece"; getObjectRequest.Key = "product_file/20151120064251-4834-index.html.zip"; // Get the path to upload the pictures string filesPath = Path.Combine(_environment.WebRootPath, "files/PieceDL"); string file1Path = Path.Combine(filesPath, getObjectRequest.Key); System.Threading.CancellationToken token; GetObjectResponse getObjectResponse = await client.GetObjectAsync(getObjectRequest); await getObjectResponse.WriteResponseStreamToFileAsync(file1Path, false, token); } } return(View("Index", buketsList)); }
public IActionResult Index() { S3BuketsList buketsList = new S3BuketsList(); return(View(buketsList)); }