public void UploadFile(S3Client targetClient, string fileName, string TargetFolder) { var fileTransferUtility = new TransferUtility(targetClient.s3Client); var fileTransferUtilityRequest = new TransferUtilityUploadRequest { BucketName = targetClient.BucketName, FilePath = fileName, StorageClass = S3StorageClass.Standard, PartSize = 6291456, // 6 MB. Key = $"{TargetFolder}/{Path.GetFileName(fileName)}" }; fileTransferUtility.Upload(fileTransferUtilityRequest); logger.Info($"{fileName} to {TargetFolder}/{Path.GetFileName(fileName)} uploaded."); }
public void TransferFilesBetweenS3(string[] args) { var source = args[1]; var target = args[2]; var targetClient = new S3Client(configuration, target); var sourceFiles = args[3]; var targetFolderName = args[4]; var files = ListFiles(sourceFiles); logger.Info($"Total Objects to tranfer {files.Count}."); foreach (var f in files) { var fileName = f.Key; var downloadedFile = DownloadFile(fileName, tempFolder); UploadFile(targetClient, downloadedFile, targetFolderName); File.Delete(downloadedFile); logger.Info($"Object {downloadedFile} was transferred to {targetFolderName}."); } }