/// <summary> /// Downloads a collection of files from S3 and writes ithem to the specified files. /// </summary> /// <param name="paths">The paths to upload.</param> /// <param name="settings">The <see cref="SyncSettings"/> required to download from Amazon S3.</param> public void Download(IList <SyncPath> paths, SyncSettings settings) { foreach (SyncPath path in paths) { try { DownloadSettings copied = new DownloadSettings() { WorkingDirectory = settings.WorkingDirectory, AccessKey = settings.AccessKey, SecretKey = settings.SecretKey, Credentials = settings.Credentials, Region = settings.Region, BucketName = settings.BucketName, EncryptionMethod = settings.EncryptionMethod, EncryptionKey = settings.EncryptionKey, EncryptionKeyMD5 = settings.EncryptionKeyMD5 }; this.Download(path.Path, path.Key, "", copied); } catch (Exception ex) { _Log.Error(ex.Message); } } }
/// <summary> /// Creates a new instance of the <see cref="DownloadSettings" /> class with the current settings. /// </summary> public DownloadSettings Copy() { DownloadSettings copy = this.CopyS3Settings(new DownloadSettings()); copy.ModifiedDate = this.ModifiedDate; return(copy); }
/// <summary> /// Specifies the date the file was last modified /// </summary> /// <param name="settings">The Download settings.</param> /// <param name="modifiedDate">The modified date.</param> /// <returns>The same <see cref="DownloadSettings"/> instance so that multiple calls can be chained.</returns> public static DownloadSettings SetModifiedDate(this DownloadSettings settings, DateTime modifiedDate) { if (settings == null) { throw new ArgumentNullException("settings"); } settings.ModifiedDate = modifiedDate; return(settings); }
/// <summary> /// Opens a stream of the content from Amazon S3 /// </summary> /// <param name="key">The key under which the Amazon S3 object is stored.</param> /// <param name="version">The identifier for the specific version of the object to be downloaded, if required.</param> /// <param name="settings">The <see cref="DownloadSettings"/> required to download from Amazon S3.</param> /// <returns>A stream.</returns> public Stream Open(string key, string version, DownloadSettings settings) { TransferUtility utility = this.GetUtility(settings); TransferUtilityOpenStreamRequest request = this.CreateOpenRequest(settings); request.Key = key; if (!String.IsNullOrEmpty(version)) { request.VersionId = version; } _Log.Verbose("Opening stream {0} from bucket {1}...", key, settings.BucketName); return(utility.OpenStream(request)); }
/// <summary> /// Get the byte array of the content from Amazon S3 /// </summary> /// <param name="key">The S3 object key.</param> /// <param name="version">The S3 object version.</param> /// <param name="settings">The download settings.</param> /// <returns>A byte array.</returns> public byte[] GetBytes(string key, string version, DownloadSettings settings) { byte[] data; using (Stream input = this.Open(key, version, settings)) { using (MemoryStream ms = new MemoryStream()) { input.CopyTo(ms); data = ms.ToArray(); } input.Close(); } return(data); }
private TransferUtilityOpenStreamRequest CreateOpenRequest(DownloadSettings settings) { TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest(); request.BucketName = settings.BucketName; request.ServerSideEncryptionCustomerProvidedKey = settings.EncryptionKey; request.ServerSideEncryptionCustomerProvidedKeyMD5 = settings.EncryptionKeyMD5; request.ServerSideEncryptionCustomerMethod = settings.EncryptionMethod; if (!String.IsNullOrEmpty(settings.EncryptionKey)) { request.ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256; } request.ModifiedSinceDate = settings.ModifiedDate; return(request); }
/// <summary> /// Downloads the content from Amazon S3 and writes it to the specified file. /// </summary> /// <param name="filePath">The file path of the file to upload.</param> /// <param name="key">The key under which the Amazon S3 object is stored.</param> /// <param name="version">The identifier for the specific version of the object to be downloaded, if required.</param> /// <param name="settings">The <see cref="DownloadSettings"/> required to download from Amazon S3.</param> public void Download(FilePath filePath, string key, string version, DownloadSettings settings) { TransferUtility utility = this.GetUtility(settings); TransferUtilityDownloadRequest request = this.CreateDownloadRequest(settings); this.SetWorkingDirectory(settings); string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath; request.FilePath = fullPath; request.Key = key; if (!String.IsNullOrEmpty(version)) { request.VersionId = version; } request.WriteObjectProgressEvent += new EventHandler <WriteObjectProgressArgs>(this.WriteObjectProgressEvent); _Log.Verbose("Downloading file {0} from bucket {1}...", key, settings.BucketName); utility.Download(request); }
public static async Task<byte[]> GetS3Bytes(this ICakeContext context, string key, DownloadSettings settings) { return await context.GetS3Bytes(key, "", settings); }
public static async Task<byte[]> GetS3Bytes(this ICakeContext context, string key, string version, DownloadSettings settings) { return await context.CreateManager().GetBytes(key, version, settings); }
public static async Task S3Download(this ICakeContext context, FilePath filePath, string key, DownloadSettings settings) { await context.CreateManager().Download(filePath, key, "", settings); }
public static async Task<Stream> S3Open(this ICakeContext context, string key, string version, DownloadSettings settings) { return await context.CreateManager().Open(key, version, settings); }
public static byte[] GetS3Bytes(this ICakeContext context, string key, DownloadSettings settings) { return(context.GetS3Bytes(key, "", settings)); }
/// <summary> /// Downloads a collection of files from S3 and writes ithem to the specified files. /// </summary> /// <param name="paths">The paths to upload.</param> /// <param name="settings">The <see cref="SyncSettings"/> required to download from Amazon S3.</param> public void Download(IList<SyncPath> paths, SyncSettings settings) { foreach(SyncPath path in paths) { try { DownloadSettings copied = new DownloadSettings() { WorkingDirectory = settings.WorkingDirectory, AccessKey = settings.AccessKey, SecretKey = settings.SecretKey, Credentials = settings.Credentials, Region = settings.Region, BucketName = settings.BucketName, EncryptionMethod = settings.EncryptionMethod, EncryptionKey = settings.EncryptionKey, EncryptionKeyMD5 = settings.EncryptionKeyMD5 }; this.Download(path.Path, path.Key, "", copied); } catch (Exception ex) { _Log.Error(ex.Message); } } }
public static string GetS3String(this ICakeContext context, string key, DownloadSettings settings) { return(context.GetS3String(key, "", settings)); }
public static void S3Download(this ICakeContext context, FilePath filePath, string key, string version, DownloadSettings settings) { context.CreateManager().Download(filePath, key, version, settings); }
public static string GetS3String(this ICakeContext context, string key, string version, DownloadSettings settings) { byte[] bytes = context.CreateManager().GetBytes(key, version, settings); if (bytes != null) { return Encoding.UTF8.GetString(bytes); } else { return ""; } }
public static string GetS3String(this ICakeContext context, string key, DownloadSettings settings) { return context.GetS3String(key, "", settings); }
/// <summary> /// Get the byte array of the content from Amazon S3 /// </summary> /// <param name="key">The S3 object key.</param> /// <param name="version">The S3 object version.</param> /// <param name="settings">The download settings.</param> /// <returns>A byte array.</returns> public byte[] GetBytes(string key, string version, DownloadSettings settings) { byte[] data; using (Stream input = this.Open(key, version, settings)) { using (MemoryStream ms = new MemoryStream()) { input.CopyTo(ms); data = ms.ToArray(); } input.Close(); } return data; }
/// <summary> /// Opens a stream of the content from Amazon S3 /// </summary> /// <param name="key">The key under which the Amazon S3 object is stored.</param> /// <param name="version">The identifier for the specific version of the object to be downloaded, if required.</param> /// <param name="settings">The <see cref="DownloadSettings"/> required to download from Amazon S3.</param> /// <returns>A stream.</returns> public Stream Open(string key, string version, DownloadSettings settings) { TransferUtility utility = this.GetUtility(settings); TransferUtilityOpenStreamRequest request = this.CreateOpenRequest(settings); request.Key = key; if (!String.IsNullOrEmpty(version)) { request.VersionId = version; } _Log.Verbose("Opening stream {0} from bucket {1}...", key, settings.BucketName); return utility.OpenStream(request); }
/// <summary> /// Downloads the content from Amazon S3 and writes it to the specified file. /// </summary> /// <param name="filePath">The file path of the file to upload.</param> /// <param name="key">The key under which the Amazon S3 object is stored.</param> /// <param name="version">The identifier for the specific version of the object to be downloaded, if required.</param> /// <param name="settings">The <see cref="DownloadSettings"/> required to download from Amazon S3.</param> public void Download(FilePath filePath, string key, string version, DownloadSettings settings) { TransferUtility utility = this.GetUtility(settings); TransferUtilityDownloadRequest request = this.CreateDownloadRequest(settings); this.SetWorkingDirectory(settings); string fullPath = filePath.MakeAbsolute(settings.WorkingDirectory).FullPath; request.FilePath = fullPath; request.Key = key; if (!String.IsNullOrEmpty(version)) { request.VersionId = version; } request.WriteObjectProgressEvent += new EventHandler<WriteObjectProgressArgs>(this.WriteObjectProgressEvent); _Log.Verbose("Downloading file {0} from bucket {1}...", key, settings.BucketName); utility.Download(request); }
public static async Task<string> GetS3String(this ICakeContext context, string key, DownloadSettings settings) { return await context.GetS3String(key, "", settings); }
public static Stream S3Open(this ICakeContext context, string key, string version, DownloadSettings settings) { return context.CreateManager().Open(key, version, settings); }
public static async Task<string> GetS3String(this ICakeContext context, string key, string version, DownloadSettings settings) { byte[] bytes = await context.CreateManager().GetBytes(key, version, settings); if (bytes != null) { return Encoding.UTF8.GetString(bytes); } else { return ""; } }
public static byte[] GetS3Bytes(this ICakeContext context, string key, string version, DownloadSettings settings) { return context.CreateManager().GetBytes(key, version, settings); }
public static Stream S3Open(this ICakeContext context, string key, string version, DownloadSettings settings) { return(context.CreateManager().Open(key, version, settings)); }
public static byte[] GetS3Bytes(this ICakeContext context, string key, DownloadSettings settings) { return context.GetS3Bytes(key, "", settings); }
public static byte[] GetS3Bytes(this ICakeContext context, string key, string version, DownloadSettings settings) { return(context.CreateManager().GetBytes(key, version, settings)); }
private TransferUtilityOpenStreamRequest CreateOpenRequest(DownloadSettings settings) { TransferUtilityOpenStreamRequest request = new TransferUtilityOpenStreamRequest(); request.BucketName = settings.BucketName; request.ServerSideEncryptionCustomerProvidedKey = settings.EncryptionKey; request.ServerSideEncryptionCustomerProvidedKeyMD5 = settings.EncryptionKeyMD5; request.ServerSideEncryptionCustomerMethod = settings.EncryptionMethod; if (!String.IsNullOrEmpty(settings.EncryptionKey)) { request.ServerSideEncryptionCustomerMethod = ServerSideEncryptionCustomerMethod.AES256; } request.ModifiedSinceDate = settings.ModifiedDate; return request; }
public static string GetS3String(this ICakeContext context, string key, string version, DownloadSettings settings) { byte[] bytes = context.CreateManager().GetBytes(key, version, settings); if (bytes != null) { return(Encoding.UTF8.GetString(bytes)); } else { return(""); } }