MultipartFormDataStreamProvider에서 상속 받아 GetLocalFileName (내용을 스트림으로 읽은 후 실행 됨) 또는 GetStream (내용을 스트림으로 읽는 중 실행 됨)을 재정의 할 수 있습니다. 두 경우 모두에 액세스 할 수 있습니다. headers.ContentDisposition.FileName
public class CustomMultipartFormDataStreamProvider : MultipartFormDataStreamProvider
{
public CustomMultipartFormDataStreamProvider(string path)
: base(path)
{
}
public override string GetLocalFileName(System.Net.Http.Headers.HttpContentHeaders headers)
{
//validate headers.ContentDisposition.FileName as it will have the name+extension
//then do something (throw error, continue with base or implement own logic)
}
public override Stream GetStream(HttpContent parent, System.Net.Http.Headers.HttpContentHeaders headers)
{
//validate headers.ContentDisposition.FileName as it will have the name+extension
//then do something (throw error, continue with base or implement own logic)
}
}