0

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); 
}
4

1 回答 1

0

有两件事:

  1. 如果您希望在 blob 存储中压缩文件,即在 blob 存储中上传大文件,并且希望 blob 存储将这些文件压缩到那里,那么这是不可能的。Blob 存储是简单的文件存储。
  2. 如果您有一个大的 zip 文件要分块上传,然后让 blob 存储重新组合这些块以创建 zip 文件,那么这是可能的。

由于您没有提到您要使用的技术,我将使用Azure REST API该过程来描述。

您需要做的是在客户端(从您上传的位置)将文件拆分为块。每个块的大小不能超过 4MB,因为块 blob 的最大大小可以是 200GB,所以不能超过 50,000 个块。Put Block然后您将使用API上传这些块。

上传所有块后,您将指示 Blob 存储使用Put Block ListAPI 创建 zip 文件。

于 2015-09-14T07:46:50.297 回答