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

  • SEARCH
  • Home
  • 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 8452943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:38:10+00:00 2026-06-10T11:38:10+00:00

What is the convention to deliver a binary resource (like a pdf file) with

  • 0

What is the convention to deliver a binary resource (like a pdf file) with a REST API? Do you just return a URL to the resource in your JSON or XML response, e.g., {“url” : “http://example.com/document.pdf”} ?

I’m trying to understand the difference between a URI and URL and keep with a RESTful philosophy. Admittedly, this is new to me so I may be misunderstanding some things.

  • 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-10T11:38:12+00:00Added an answer on June 10, 2026 at 11:38 am

    This Section Assumes You Mean: How Do I Tell The User Where to Find a Binary Resource

    The difference between a URI and a URL doesn’t have anything to do with binary vs. non-binary datatypes (see also).

    If you’re returning mostly JSON, then a url entry is a common way to go. If you’re doing something more HTML/XML-ish, then something like a <link> element with a good rel attribute makes a lot of sense.

    Obviously, if the client makes a GET request to the direct URL you gave them, then you should send them the file, unless they sent a bunch of content-negotiation headers that effectively preclude you from fulfilling their request. In that case, a 406 Not Acceptable response (or the official definition) makes a lot of sense.

    If you meant something else by your question, please clarify.

    A Rambling “Do It Like This” Section

    First: ignore URL vs. URI. It doesn’t have anything to do with this. At all.

    Next: If your problem is not “How do I link to a resource” (which might be affected by the stuff I’m about to discuss), but “What if my resource is just a PDF file”, you have all sorts of options for addressing it. First off, you need to step back and think more abstractly (a little). Your resource is almost certainly not “a PDF file”. It’s “a file uploaded by a user”, or “a PDF version of a report that I generate”, etc.

    In the first case, you probably don’t have any representation of the resource beyond the binary they sent you, which is totally fine. You probably won’t need to perform any sort of content-negotiation when you receive a GET to the URL for that resource. Just send them the file, subject to the caveats about 406 I mention above.

    In the second case, you might have all sorts of representations of this resource: CSV, HTML, LaTeX, you name it. In this case, when you receive a GET to the URL for the resource, you do need to do some content-negotiation, so you know whether to send them the PDF document, or something else. It’s possible that you might have a JSON representation of the resource that is just the raw data you use to generate the PDF.

    In either case, it would be unexpected if you had a representation that was strictly metadata about the resource. If needed (often it is, sometimes it isn’t), explicit, external metadata (as opposed to metadata embedded within the binary resource, such as author and title info in PDFs) is most commonly modeled as a separate resource.

    Finally, as @monitorjbl says: you probably don’t want to embed the binary data directly in a text format such as JSON or XML. There are ways of doing it, often involving the words “base64-encoded”, but it’s usually not the best approach. In general, you shouldn’t mix binary data and text data.

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

Sidebar

Related Questions

By convention classes are often named like nouns, methods like verbs and interfaces like
What is your naming convention for DATETIME columns (in my case, using MS SQL
Is there a good convention-based way to avoid repetitive code like the following in
The convention with using JavaMail seems to be: -- Use smtp for sending emails
What is default calling convention for a static function say: static void PrintHelloWorld(char* s)
We have a convention to validate all parameters of constructors and public functions/methods. For
I thought that by convention, only methods with an exclamation mark altered the object.
I know the naming convention for class methods in C# is to begin with
Is there a standard convention for the types of files that go in \Windows\
Is there a convention for naming private functions in bash? I have a bash

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.