Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:31:01+00:00 2026-06-01T02:31:01+00:00

This WCF Service returns a TIFF image. It checks if it is connected to

  • 0

This WCF Service returns a TIFF image. It checks if it is connected to our repository – and gets the bytes from the datafile. It checks if the file is a PDF, tiff, or image, and returns the appropriate mime type. I can now call the service and it returns the appropriate file – but with an image name of “documentID”.tif. How do I set the filename of the image it returns?

[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"));
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:31:03+00:00Added an answer on June 1, 2026 at 2:31 am

    The best way I’ve found to do this in RESTful services is using the Content-Disposition header. Most browsers support this out of the box and will pop a save as dialog with the name the header suggests. As for other clients it’s hit or miss on if they pay attention to the header, if you control the client then you can always add it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a WCF service in my project. This service returns a class
I have a wcf service which returns a bmp in byte[]. However Silverlight's Image
My AJAX-enabled WCF service returns JSON using this contract, [DataContract] public class JQGridContract {
I created WCF service that returns a custom object called XmlElementTreeNode. This is what
I have WCF service that returns an object that contains an array of bytes
I have a WCF service that returns JSON to the clients. This is the
I am trying to return some JSON from a WCF service. This service simply
This is in relation to this question I am hosting this WCF service in
I have a WCF service that is deployed on a machine. This WCF service
I have an ASP.NET page that calls to a WCF service. This WCF service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.