public List <ChunkInfo> GetCurrentChunkList(string filePath) { List <ChunkInfo> retVal = new List <ChunkInfo>(); try { byte[] buffer = new byte[this.chunkSize]; int bytesRead; int chunkIndex = 0; // chunk indices start at 0 int offset = 0; string hash; using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0) { SHA1 sha1 = new SHA1CryptoServiceProvider(); hash = Convert.ToBase64String(sha1.ComputeHash(buffer, 0, bytesRead)); retVal.Add(new ChunkInfo(chunkIndex, bytesRead, hash, offset)); chunkIndex++; offset += bytesRead; } fs.Close(); } } catch (Exception e) { AzureHelper.structuredLog("E", e.Message + ". GetStaticChunks: " + filePath + ". " + e); } return(retVal); }
private object UploadFileToBlockBlob_worker(object state) { string filePath = (string)state; bool retVal = azureHelper.UploadFileToBlockBlob(Path.GetFileName(filePath), filePath); if (!retVal) { AzureHelper.structuredLog("E", "UploadFile for {0} failed ", filePath); } return(null); }