이 WCF 서비스는 TIFF 이미지를 반환합니다. 저장소에 연결되어 있는지 확인하고 데이터 파일에서 바이트를 가져옵니다. 파일이 PDF, tiff 또는 이미지인지 확인하고 적절한 MIME 유형을 리턴합니다. 이제 서비스를 호출 할 수 있으며 적절한 파일을 반환하지만 이미지 이름은 "documentID".tif입니다. 반환하는 이미지의 파일 이름은 어떻게 설정합니까?이 WCF 서비스는 TIFF 이미지를 반환합니다. 반환하는 이미지의 파일 이름은 어떻게 설정합니까?
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate="File/{documentID}")]
Stream GetDocumentFile_GET(string documentID);
public Stream GetDocumentFile_GET(string documentID)
{
if (ProprietaryClass.IsConnected)
{
ProprietaryClass _documentForViewer = new ProprietaryClass(documentID);
string _fileType = ProprietaryClass.NativeFileType;
string _mimetype = "image/tiff";
switch (_fileType)
{
case "TIF":
_mimetype = "image/tiff";
break;
case "PDF":
_mimetype = "application/pdf";
break;
case "PNG":
_mimetype = "image/png";
break;
};
if (ProprietaryClass.ProprietaryMethod(_documentForViewer))
{
ProprietaryClass _downloadToViewer = new ProprietaryClass();
if (_documentForViewer.TiffFile != null)
{
_downloadToViewer = _documentForViewer.TiffFile;
}
else
{
_downloadToViewer = _documentForViewer.NativeFile;
}
MemoryStream fileStream = new MemoryStream(_downloadToViewer.FileData);
// fileStream is now array of bytes
System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.ContentType = _mimetype;
return (Stream)fileStream;
}
else
{
return new MemoryStream(Encoding.UTF8.GetBytes("Document type not supported by native viewer"));
}
}
else
{
return new MemoryStream(Encoding.UTF8.GetBytes("Not connected"));
}
}
이것은 지금까지 나를 위해 일했다. –