서비스를 테스트하기 위해 피들 디버거에서 비디오 파일 .mov를 원격 웹 서비스에 업로드하려하지만 디스크에 저장된 파일이 손상되었습니다. 어떤 제안?바이너리 업로드 WCF가 손상되었습니다. .mov 파일
요청 헤더
Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
User-Agent: Fiddler
Host: localhost:2487
Content-Length: 2113228
요청 본문
---------------------------acebdf13572468
Content-Disposition: form-data; name="IMG_0888.MOV"; filename="IMG_0888.MOV"
Content-Type: video/quicktime
<@INCLUDE *C:\Users\Amrit\Desktop\IMG_0888.MOV*@>
---------------------------acebdf13572468--
C# 코드
FileStream fs = null;
string UniqueId = this.GenerateUID();
_fileDirectory = System.IO.Path.Combine(Constants._VideosDirectory,author_id);
if (!Directory.Exists(_fileDirectory))
{
Directory.CreateDirectory(_fileDirectory);
}
string file = Path.Combine(_fileDirectory, "test.mov");
// string filePath = Path.Combine(uploadFolder, request.FileName);
try
{
using (FileStream targetStream = new FileStream(file, FileMode.Create,
FileAccess.Write, FileShare.None))
{
//read from the input stream in 65000 byte chunks
const int bufferLen = 65000;
byte[] buffer = new byte[bufferLen];
int count = 0;
while ((count = request.Read(buffer, 0, bufferLen)) > 0)
{
// save to output stream
targetStream.Write(buffer, 0, count);
}
targetStream.Close();
return "done";
//sourceStream.Close();
}
}
catch (Exception)
{
return "fail";
}
finally
{
}
은 전체 요청을 디스크에 저장하기 때문에 발생할 수 있습니다. 요청을 받아 들여 실제 파일 내용을 가져와야합니다. –
고마워요 @AndrasZoltan – Amrit