현재 C# RestClient를 사용하여 웹 API에서 파일을 다운로드하고 있습니다.WebAPI - 파일 다운로드 체크섬?
[HttpGet]
public HttpResponseMessage Generate()
{
var stream = new MemoryStream();
// processing the stream.
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(stream.GetBuffer())
};
result.Content.Headers.ContentDisposition =
new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
{
FileName = "CertificationCard.pdf"
};
result.Content.Headers.ContentType =
new MediaTypeHeaderValue("application/octet-stream");
return result;
}
이에서 촬영 : 이 내 현재 코드는 웹 API 부분에서 파일을 반환하는 것입니다 How to return a file (FileContentResult) in ASP.NET WebAPI
내 질문은 다음이다, 내가 파일이 제대로 다운로드되었는지 검증 할 수있는 방법은 - 내가 할 수있는 어떻게 든 ByteArray에 MD5 체크섬을 제공하고 RestClient에서 이것을 체크해야 하는가?
게시 참조 : http://stackoverflow.com/questions/10520048/calculate-md5-checksum-for -a-file – jdweng
파일 해시를 생성하고 응답 헤더로 추가하고 클라이언트에서 다운로드가 완료되는지 확인합니다. 이것은 처리해야 할 TCP 오류 정정 기능 이외의 스트림이나 네트워크 문제에서 데이터가 손상 될 가능성이 있다고 생각하는 경우에만 의미가 있습니다. 이것이 필요한 방법은 판단입니다. http://serverfault.com/questions/692457/why-is-it-good-practice-to-compare-checksums-when-downloading-a-file –
Thanks @AlexK를 참조하십시오. 헤더에 MD5Hash를 추가하고 완벽하게 작동했습니다! :-) 대답 – Mathias