com.vzaar.api.Vzaar.multipartUpload C# (CSharp) Method

multipartUpload() private method

Upload video from local drive in multiple chunks
private multipartUpload ( string path, UploadSignature signature ) : string
path string Path of the video file to be uploaded
signature UploadSignature Object of type
return string
        private string multipartUpload(string path, UploadSignature signature)
        {
            string guid = null;
            var fileInfo = new FileInfo(path);
            long filesize = fileInfo.Length;
            int chunks = (int)Math.Ceiling((double)filesize / chunkSyzeInBytes(signature.chunkSize));
            var buffer = new byte[chunkSyzeInBytes("5mb")];
            int bytesRead;
            var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
            int chunk = 0;
            while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
            {
                MemoryStream ms = new MemoryStream(buffer, 0, bytesRead);

                string key = signature.key.Replace("${filename}", fileInfo.Name) + "." + chunk;
                var parameters = new NameValueCollection
                                 {
                                     {"AWSAccessKeyId", signature.accessKeyId},
                                     {"signature", signature.signature},
                                     {"acl", signature.acl},
                                     {"bucket", signature.bucket},
                                     {"policy", signature.policy},
                                     {"success_action_status", "201"},
                                     {"key", key},
                                     {"chunks", chunks.ToString()},
                                     {"chunk", chunk.ToString()},
                                     {"x-amz-meta-uploader", uploader}
                                 };

                guid = HttpUploadFile(signature.uplodHostname, parameters, ms, path);
                chunk++;
                ms.Close();
                ms.Dispose();
            }
            fileStream.Close();

            return guid;
        }
        private string HttpUploadFile(string url, NameValueCollection nvc, Stream stream, string file)