コード例 #1
0
ファイル: BAwsSDK.cs プロジェクト: Pxndit4/Easylife
        public static bool UploadS3(MAwsS3 mAwsS3, string localFilePath, string subDirectoryInBucket, string fileNameInS3)
        {
            try
            {
                AWSCredentials credentials;
                credentials = new BasicAWSCredentials(UEncrypt.Decrypt(mAwsS3.AccessKey.Trim()), UEncrypt.Decrypt(mAwsS3.SecretKey.Trim()));
                IAmazonS3 client = new AmazonS3Client(credentials, RegionEndpoint.USEast2);

                TransferUtility utility = new TransferUtility(client);
                TransferUtilityUploadRequest request = new TransferUtilityUploadRequest();

                if (subDirectoryInBucket == "" || subDirectoryInBucket == null)
                {
                    request.BucketName = UEncrypt.Decrypt(mAwsS3.BucketName); //no subdirectory just bucket name
                }
                else
                { // subdirectory and bucket name
                    request.BucketName = UEncrypt.Decrypt(mAwsS3.BucketName) + @"/" + subDirectoryInBucket;
                }

                request.Key       = fileNameInS3;  //file name up in S3
                request.FilePath  = localFilePath; //local file name
                request.CannedACL = S3CannedACL.PublicRead;
                utility.Upload(request);           //commensing the transfer

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: DonorController.cs プロジェクト: Pxndit4/Easylife
 public DonorController(IWebHostEnvironment env, IOptions <AppSettings> appSettings, IOptions <MAwsEmail> MAwsEmail, IOptions <MAwsS3> MAwsS3)
 {
     _env         = env;
     _appSettings = appSettings;
     _MAwsEmail   = MAwsEmail.Value;
     _MAwsS3      = MAwsS3.Value;
 }
コード例 #3
0
 public ProfileController(IOptions <AppSettings> appSettings, IOptions <MAwsEmail> MAwsEmail, IOptions <MAwsS3> MAwsS3)
 {
     _appSettings = appSettings;
     _MAwsEmail   = MAwsEmail.Value;
     _MAwsS3      = MAwsS3.Value;
 }