コード例 #1
0
        /*
         * downloads file form s3
         */
        public static bool DownloadFileFromS3(IAmazonS3 s3Client, string bucketName, string objectKey, string filePath)
        {
            IDictionary <string, object> dic = new Dictionary <string, object>();
            bool rc = true;

            try
            {
                s3Client.DownloadToFilePath(bucketName, objectKey, filePath, dic);
            }
            catch (AmazonS3Exception ex)
            {
                rc = false;
                if (ex.ErrorCode != null && (ex.ErrorCode.Equals("InvalidAccessKeyId") ||
                                             ex.ErrorCode.Equals("InvalidSecurity")))
                {
                    logger.Error("Please check the provided AWS Credentials.");
                }
                else
                {
                    logger.Error("Caught Exception: " + ex.Message);
                    logger.Error("Response Status Code: " + ex.StatusCode);
                    logger.Error("Error Code: " + ex.ErrorCode);
                    logger.Error("Request ID: " + ex.RequestId);
                }
            }
            return(rc);
        }
コード例 #2
0
 public void DownloadFile(string source, string destination)
 {
     try
     {
         _client.DownloadToFilePath(_bucketPath, source, destination, null);
     }
     catch (Exception ex)
     {
         $"Download of file {source} failed, with error message: {ex.Message}".WriteErrorToConsole();
         throw;
     }
 }