I want to know that.. If I make chunks of a big Zip file and upload all chunks on Azure Cloud Storage in Container Blobs. Can i Join these chunks on Azure Platform.? for chunking i am using this code which is also generating .bat file for rejoining the chunks..
public void SplitFile(){
int numericUpDown = 100;//in MB
string PathToCopyChunks = ""; // path to store chunks and ( .bat ) file
string FilePathMakeChunks = DirectoryNameToPutScannedData; //the path of file to make chunks.
try{
int kbs = numericUpDown * 1024;
int chunkSize = numericUpDown * 1024 * 1024;
byte[] buffer = new byte[4096];
string cmdout = "copy/b ";
FileStream infile = File.OpenRead(FilePathMakeChunks);
for (long i = 0; i <= infile.Length / chunkSize; i++)
{
string fname = Path.Combine(PathToCopyChunks, Path.Combine(PathToCopyChunks, Path.GetFileName(FilePathMakeChunks)) + "." + chunkSize + "." + i.ToString().PadLeft(4, '0') + ".part");
string fname_x = Path.GetFileName(FilePathMakeChunks) + "." + chunkSize + "." + i.ToString().PadLeft(4, '0') + ".part";
if (i == infile.Length / chunkSize)
cmdout += "\"" + fname_x + "\"";
else
cmdout += "\"" + fname_x + "\" + ";
FileStream outfile = File.Create(fname);
for (int kb = 0; kb <= kbs; kb++)
{
int len = infile.Read(buffer, 0, 1024);
outfile.Write(buffer, 0, len);
}
outfile.Close();
}
cmdout += " \"" + Path.GetFileName(FilePathMakeChunks) + "\"";
string combinerbatch = Path.Combine(PathToCopyChunks, Path.Combine(PathToCopyChunks, Path.GetFileName(DirectoryNameToPutScannedData)) + "." + chunkSize + ".combine.bat");
File.WriteAllText(combinerbatch, cmdout);
MessageBox.Show("Splitting Done...!");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
I am uploading these chunks along with batch file in azure storage container and i want to run this batch file at my azure container to join chunks. hope this will help to understand my Question
And I am using this code for Uploading
string[] array1 = Directory.GetFiles(@"D:\Test");
string fileName = string.Empty;
foreach (string name in array1)
{
fileName = Path.GetFileName(name);
CloudBlockBlob blockBlob = container.GetBlockBlobReference(fileName);
var fileStream = System.IO.File.OpenRead(name);
blockBlob.UploadFromStream(fileStream);
}