コード例 #1
0
        public TRequest AddMulitpartFile(byte[] datas, int blocknum, long blockSize, string fileName, string contentType, long totalSize, long blockCount)
        {
            int index = blocknum;

            var name = fileName;

            _mulitpartFile = new MulitpartFile(datas, index, name, fileName, blockSize, contentType, totalSize, blockCount);

            return(This());
        }
コード例 #2
0
        public TRequest AddMulitpartFile(List <byte[]> datas, int blocknum, long blockSize, string fileName, string contentType, long totalSize, long blockCount)
        {
            int index = blocknum;

            foreach (var data in datas)
            {
                var name           = $"{index}-{fileName}";
                var _mulitpartFile = new MulitpartFile(data, index, name, fileName, blockSize, contentType, totalSize, blockCount);
                _mulitpartFiles.Add(_mulitpartFile);
                index++;
            }

            return(This());
        }
コード例 #3
0
ファイル: HttpRequestBase.cs プロジェクト: vickytqy/IM-SDK
        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);
        }