ReturnData uploadChunk(byte[] chunk) { UploadToAzure uploadToAzure = new UploadToAzure(); var res = uploadToAzure.UploadChunk(CurrentChunk, chunk); return(res); }
void UploadVideo() { UploadToAzure uploadToAzure = new UploadToAzure(); using (var file = File.OpenRead(Program.Localpath + "//output.mp4")) { int bytesRead; var buffer = new byte[file.Length]; while ((bytesRead = file.Read(buffer, 0, buffer.Length)) > 0) { } byte[][] vs = BufferSplit(buffer, chunkSize); long filesize = file.Length; long totalChunk = vs.Length; string FileName = Guid.NewGuid().ToString(); uploadToAzure.SetMetadata((int)totalChunk, FileName, filesize, ""); for (int i = 0; i < totalChunk; i++) { CurrentChunk = i + 1; var res = uploadChunk(vs[i]); Thread.Sleep(10); if (res.isLastBlock) { timer1.Enabled = false; DLOperation dLOperation = new DLOperation(); dLOperation.SaveEntry(ClsCommon.UserId, Program.cloudFile.BlockBlob.SnapshotQualifiedStorageUri.PrimaryUri.ToString(), 2); } } } Environment.Exit(1); }
void UploadVideo() { UploadToAzure uploadToAzure = new UploadToAzure(); using (var file = File.OpenRead(Program.Localpath + "//output.mp4")) { int bytesRead; var buffer = new byte[file.Length]; while ((bytesRead = file.Read(buffer, 0, buffer.Length)) > 0) { } byte[][] vs = BufferSplit(buffer, chunkSize); long filesize = file.Length; long totalChunk = vs.Length; string FileName = Guid.NewGuid().ToString(); uploadToAzure.SetMetadata((int)totalChunk, FileName, filesize, ""); for (int i = 0; i < totalChunk; i++) { CurrentChunk = i + 1; var res = uploadChunk(vs[i]); Thread.Sleep(10); if (res.isLastBlock) { // timer1.Enabled = false; DLOperation dLOperation = new DLOperation(); dLOperation.SaveEntry(ClsCommon.UserId, Program.cloudFile.BlockBlob.SnapshotQualifiedStorageUri.PrimaryUri.ToString(), 2); } int percent = (CurrentChunk * 100 / (int)totalChunk); progressBar1.Invoke(new MethodInvoker(() => { progressBar1.Value = percent; progressBar1.Update(); })); lblProgress.Invoke(new MethodInvoker(() => { lblProgress.Text = percent.ToString() + " %"; lblProgress.Update(); })); } } this.Invoke(new MethodInvoker(() => { MessageBox.Show(this, "Content Captured. Press OK to continue submission."); })); Environment.Exit(1); }