내 Outlook 플러그인이 https를 통해 대용량 파일을 보냅니다. 현재 클라이언트 측 Convert.ToBase64String() 및 IIS 측 http 핸들러 Convert.FromBase64String()을 사용하고 있습니다.Base64 인코딩없이 https를 통해 바이트 배열을 보내는 방법은 무엇입니까?
이것은 약간의 성능 문제가 발생했습니다. 또한 SSL을 통한 데이터 보안을 유지하므로 https를 통해 바이트 배열을 변환 할 방법이 있는지 질문합니다. 받는 사람 끝.
내 고객 코드 :string requestURL = "http://192.168.1.46/websvc/transfer.trn";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURL);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
// Chunk(buffer) is converted to Base64 string that will be convert to Bytes on the handler.
string requestParameters = @"fileName=" + fileName + @"&secretKey=testKey=" + @"¤tChunk=" + i + @"&totalChunks=" + totalChunks + @"&smGuid=" + smGuid +
"&data=" + HttpUtility.UrlEncode(Convert.ToBase64String(bytes));
// finally whole request will be converted to bytes that will be transferred to HttpHandler
byte[] byteData = Encoding.UTF8.GetBytes(requestParameters);
request.ContentLength = byteData.Length;
Stream writer = request.GetRequestStream();
writer.Write(byteData, 0, byteData.Length);
writer.Close();
// here we will receive the response from HttpHandler
StreamReader stIn = new StreamReader(request.GetResponse().GetResponseStream());
string strResponse = stIn.ReadToEnd();
stIn.Close();
Server 코드 나 성능 문제가있다 : 당신은 WCF 데이터 서비스를 사용하는 경우
byte[] buffer = Convert.FromBase64String(context.Request.Form["data"]); //
원래 이것은 WCF 웹 서비스 였지만 패딩의 양은 가치가있는 것보다 훨씬 많은 오버 헤드가 발생했습니다. 나는 간단한 사진을 보내고 있지만 매우 큰 파일 (> 1 기가 바이트)이 아니야 언급해야합니다. 나는 frint 끝과 백엔드를 완전히 바꾸지 않으려 고합니다. 아마도 코드를 제 위치에서 사용하는 더 효율적인 방법 일 것입니다. –
내 대답에 HttpWebRequest를 사용하는 옵션이 추가되었습니다. –
@ gui_s3 : Oopps는 우연히 그것을 코드 블록으로 바꾼 들여 쓰기가 있습니다 :-) 편집 됨. –