It seems kind of weird to do a blog post around a feature that’s fairly well documented, but this came up twice this week, so I figured I’d throw it out there.
Scenario: I want to post up a record to be inserted into a table. The record will consist of a couple of regular values, but also a file, which will be stored as a BLOB.
Ok, how does this happen?
Let’s start from the POST request perspective.
We’re going to send the ‘regular’ data via the header as parameters.
The file is going to go up in the BODY of the request.
What does ORDS do with this?
The secret sauce bits, which are discussed in the docs here, is that ORDS auto binds the data from the body to :body.
It’s only avail on a POST or PUT.
This makes doing our INSERT very easy.
The other two values are plucked off the request headers:
And that’s it, really.
So the request from POSTMAN goes up, and into my table goes the BLOB.
Step by Step Example
You can build this same scenario yourself – exact same code I used, it’s in our DOCS.