public System.IAsyncResult BeginContinueUpload(Uploader.Client.FileReceiver.ChunkUploadRequest request, System.AsyncCallback callback, object asyncState) { object[] _args = new object[1]; _args[0] = request; System.IAsyncResult _result = base.BeginInvoke("ContinueUpload", _args, callback, asyncState); return(_result); }
public void Send() { try { //send first chunk, start upload. FileReceiver.FileReceiverClient client = new Uploader.Client.FileReceiver.FileReceiverClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utility.BaseUrl + "Services/FileReceiver.svc"); client.BeginUploadCompleted += new EventHandler <Uploader.Client.FileReceiver.BeginUploadCompletedEventArgs>(client_BeginUploadCompleted); FileReceiver.ChunkUploadRequest req = new Uploader.Client.FileReceiver.ChunkUploadRequest(); using (FileStream fs = this.File.OpenRead()) { //get full hash first. this.FileLength = fs.Length; //setup progress bar. this.Steps = (int)(this.FileLength / (long)Utility.chunkSize); this.uxProgress.Minimum = 0; this.uxProgress.Maximum = this.Steps; int read = 0; byte[] buffer = null; if (fs.Length <= Utility.chunkSize) { buffer = new byte[(int)fs.Length]; } else { buffer = new byte[Utility.chunkSize]; } read = fs.Read(buffer, 0, Utility.chunkSize); this.FilePosition += read; req.Chunk = buffer; req.ChunkSize = buffer.Length; req.Hash = Utility.GetSHA256Hash(buffer); client.BeginUploadAsync(req); } } catch (Exception ex) { //show error. this.uxText.Text = ex.Message; } }
public void Send() { try { //send first chunk, start upload. FileReceiver.FileReceiverClient client = new Uploader.Client.FileReceiver.FileReceiverClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utility.BaseUrl + "Services/FileReceiver.svc"); client.BeginUploadCompleted += new EventHandler<Uploader.Client.FileReceiver.BeginUploadCompletedEventArgs>(client_BeginUploadCompleted); FileReceiver.ChunkUploadRequest req = new Uploader.Client.FileReceiver.ChunkUploadRequest(); using (FileStream fs = this.File.OpenRead()) { //get full hash first. this.FileLength = fs.Length; //setup progress bar. this.Steps = (int)(this.FileLength / (long)Utility.chunkSize); this.uxProgress.Minimum = 0; this.uxProgress.Maximum = this.Steps; int read = 0; byte[] buffer = null; if (fs.Length <= Utility.chunkSize) buffer = new byte[(int)fs.Length]; else buffer = new byte[Utility.chunkSize]; read = fs.Read(buffer, 0, Utility.chunkSize); this.FilePosition += read; req.Chunk = buffer; req.ChunkSize = buffer.Length; req.Hash = Utility.GetSHA256Hash(buffer); client.BeginUploadAsync(req); } } catch (Exception ex) { //show error. this.uxText.Text = ex.Message; } }
public void ContinueUploadAsync(Uploader.Client.FileReceiver.ChunkUploadRequest request, object userState) { if ((this.onBeginContinueUploadDelegate == null)) { this.onBeginContinueUploadDelegate = new BeginOperationDelegate(this.OnBeginContinueUpload); } if ((this.onEndContinueUploadDelegate == null)) { this.onEndContinueUploadDelegate = new EndOperationDelegate(this.OnEndContinueUpload); } if ((this.onContinueUploadCompletedDelegate == null)) { this.onContinueUploadCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnContinueUploadCompleted); } base.InvokeAsync(this.onBeginContinueUploadDelegate, new object[] { request }, this.onEndContinueUploadDelegate, this.onContinueUploadCompletedDelegate, userState); }
void SendNextChunk(Guid token) { try { FileReceiver.FileReceiverClient client = new Uploader.Client.FileReceiver.FileReceiverClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utility.BaseUrl + "Services/FileReceiver.svc"); client.ContinueUploadCompleted += new EventHandler <Uploader.Client.FileReceiver.ContinueUploadCompletedEventArgs>(client_ContinueUploadCompleted); FileReceiver.ChunkUploadRequest req = new Uploader.Client.FileReceiver.ChunkUploadRequest(); using (FileStream fs = this.File.OpenRead()) { int read = 0; byte[] buffer = null; int readSize = Utility.chunkSize; long diff = this.FileLength - this.FilePosition; if (diff < Utility.chunkSize) { readSize = (int)diff; } buffer = new byte[readSize]; fs.Seek(this.FilePosition, SeekOrigin.Begin); read = fs.Read(buffer, 0, readSize); this.FilePosition += read; req.ChunkSize = buffer.Length; req.Hash = Utility.GetSHA256Hash(buffer); req.Chunk = buffer; req.Token = token; client.ContinueUploadAsync(req); } } catch (Exception ex) { //show error. this.uxText.Text = ex.Message; } }
public void ContinueUploadAsync(Uploader.Client.FileReceiver.ChunkUploadRequest request) { this.ContinueUploadAsync(request, null); }
private System.IAsyncResult OnBeginContinueUpload(object[] inValues, System.AsyncCallback callback, object asyncState) { Uploader.Client.FileReceiver.ChunkUploadRequest request = ((Uploader.Client.FileReceiver.ChunkUploadRequest)(inValues[0])); return(((Uploader.Client.FileReceiver.IFileReceiver)(this)).BeginContinueUpload(request, callback, asyncState)); }
System.IAsyncResult Uploader.Client.FileReceiver.IFileReceiver.BeginContinueUpload(Uploader.Client.FileReceiver.ChunkUploadRequest request, System.AsyncCallback callback, object asyncState) { return(base.Channel.BeginContinueUpload(request, callback, asyncState)); }
public void BeginUploadAsync(Uploader.Client.FileReceiver.ChunkUploadRequest request) { this.BeginUploadAsync(request, null); }
void SendNextChunk(Guid token) { try { FileReceiver.FileReceiverClient client = new Uploader.Client.FileReceiver.FileReceiverClient(); client.Endpoint.Address = new System.ServiceModel.EndpointAddress(Utility.BaseUrl + "Services/FileReceiver.svc"); client.ContinueUploadCompleted += new EventHandler<Uploader.Client.FileReceiver.ContinueUploadCompletedEventArgs>(client_ContinueUploadCompleted); FileReceiver.ChunkUploadRequest req = new Uploader.Client.FileReceiver.ChunkUploadRequest(); using (FileStream fs = this.File.OpenRead()) { int read = 0; byte[] buffer = null; int readSize = Utility.chunkSize; long diff = this.FileLength - this.FilePosition; if (diff < Utility.chunkSize) readSize = (int)diff; buffer = new byte[readSize]; fs.Seek(this.FilePosition, SeekOrigin.Begin); read = fs.Read(buffer, 0, readSize); this.FilePosition += read; req.ChunkSize = buffer.Length; req.Hash = Utility.GetSHA256Hash(buffer); req.Chunk = buffer; req.Token = token; client.ContinueUploadAsync(req); } } catch (Exception ex) { //show error. this.uxText.Text = ex.Message; } }