private MultipartFormContent CreateMulitpartFileContent(MulitpartFile mulitpartFile) { var multipartFormContent = new MultipartFormContent(); var fileNameContent = new StringContent(mulitpartFile.Filename); fileNameContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "fileName" }; multipartFormContent.Add(fileNameContent); var blockCountContent = new StringContent(mulitpartFile.BlockCount.ToString()); blockCountContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "blockCount" }; multipartFormContent.Add(blockCountContent); var totalSizeContent = new StringContent(mulitpartFile.TotalSize.ToString()); totalSizeContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "totalSize" }; multipartFormContent.Add(totalSizeContent); var businessTypeContent = new StringContent(mulitpartFile.businessType.ToString()); businessTypeContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "businessType" }; multipartFormContent.Add(businessTypeContent); var fc = new MulitpartFileContent(mulitpartFile.Data, mulitpartFile.Name, mulitpartFile.Blocknum, mulitpartFile.Blocksize, mulitpartFile.FileName, mulitpartFile.ContentType); multipartFormContent.Add(fc); return(multipartFormContent); }
private MultipartFormContent CreateMulitpartFileContent(List <MulitpartFile> mulitpartFiles) { var multipartFormContent = new MultipartFormContent(); foreach (var mulitpartFile in mulitpartFiles) { var fileNameContent = new StringContent(mulitpartFile.Filename); fileNameContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "fileName" }; multipartFormContent.Add(fileNameContent); var blockCountContent = new StringContent(mulitpartFile.BlockCount.ToString()); blockCountContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "blockCount" }; multipartFormContent.Add(blockCountContent); var totalSizeContent = new StringContent(mulitpartFile.TotalSize.ToString()); totalSizeContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "totalSize" }; multipartFormContent.Add(totalSizeContent); var fc = new MulitpartFileContent(mulitpartFile.Data, mulitpartFile.Name, mulitpartFile.Blocknum, mulitpartFile.Blocksize, mulitpartFile.FileName, mulitpartFile.ContentType); fc.Headers.ContentDisposition.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("blocknum", mulitpartFile.Blocknum.ToString())); fc.Headers.ContentDisposition.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("blocksize", mulitpartFile.Blocksize.ToString())); multipartFormContent.Add(fc); } return(multipartFormContent); }