using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace Amazon.DynamoDBv2.DataModel { public partial class S3Link { #region Upload/PutObject /// /// Initiates the asynchronous execution of the UploadFrom operation. /// /// Path of the file to be uploaded. /// An AsyncCallback delegate that is invoked when the operation completes /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property public IAsyncResult BeginUploadFrom(string sourcePath, AsyncCallback callback, object state) { return this.s3ClientCache.GetClient(this.RegionAsEndpoint).BeginUploadObjectFromFilePath( this.linker.s3.bucket, this.linker.s3.key, sourcePath, null, callback, state); } /// /// Finishes the asynchronous execution of the UploadFrom operation. /// /// The IAsyncResult returned by the call to BeginUploadFrom. public void EndUploadFrom(IAsyncResult asyncResult) { this.s3ClientCache.GetClient(this.RegionAsEndpoint).EndUploadObjectFromFilePath(asyncResult); } /// /// Initiates the asynchronous execution of the UploadStream operation. /// /// The stream of data to upload. /// An AsyncCallback delegate that is invoked when the operation completes /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property public IAsyncResult BeginUploadStream(Stream stream, AsyncCallback callback, object state) { return this.s3ClientCache.GetClient(this.RegionAsEndpoint).BeginUploadObjectFromStream( this.linker.s3.bucket, this.linker.s3.key, stream, null, callback, state); } /// /// Finishes the asynchronous execution of the UploadStream operation. /// /// The IAsyncResult returned by the call to BeginUploadStream. public void EndUploadStream(IAsyncResult asyncResult) { this.s3ClientCache.GetClient(this.RegionAsEndpoint).EndUploadObjectFromStream(asyncResult); } #endregion #region Download/GetObject /// /// Initiates the asynchronous execution of the DownloadTo operation. /// /// Path to save the file. /// An AsyncCallback delegate that is invoked when the operation completes /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property public IAsyncResult BeginDownloadTo(string downloadPath, AsyncCallback callback, object state) { return this.s3ClientCache.GetClient(this.RegionAsEndpoint).BeginDownloadToFilePath( this.linker.s3.bucket, this.linker.s3.key, downloadPath, null, callback, state); } /// /// Finishes the asynchronous execution of the DownloadTo operation. /// /// The IAsyncResult returned by the call to BeginDownloadTo. public void EndDownloadTo(IAsyncResult asyncResult) { this.s3ClientCache.GetClient(this.RegionAsEndpoint).EndDownloadToFilePath(asyncResult); } /// /// Initiates the asynchronous execution of the OpenStream operation. /// /// An AsyncCallback delegate that is invoked when the operation completes /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property public IAsyncResult BeginOpenStream(AsyncCallback callback, object state) { return this.s3ClientCache.GetClient(this.RegionAsEndpoint).BeginGetObjectStream( this.linker.s3.bucket, this.linker.s3.key, null, callback, state); } /// /// Finishes the asynchronous execution of the OpenStream operation. /// /// The IAsyncResult returned by the call to BeginOpenStream. public Stream EndOpenStream(IAsyncResult asyncResult) { return this.s3ClientCache.GetClient(this.RegionAsEndpoint).EndGetObjectStream(asyncResult); } #endregion } }