Hi,
I've been searching extensively for days, but haven't found the solution yet.
My objective is to invoke a WS from PLSQL using UTL_HTTP, but the content is a file (image, or other) stored as BLOB field in a table.
I have no problems invoking other WSs in the normal JSON format an treating the output with PLSQL. The problem exists only when i want to upload a file.
The WS in question expects this:
Upload file to tickets:
Post to http://{IP/DNS}/upload/upload2tickets.php
Body parameters:
|
key
|
value
|
description
|
|
file
(required)
| 111.pdf | file to send |
If i use Postman, i am able to call it successfuly, choosing (in the body) form-data, selecting file, uploading the file and hitting "SEND":

However if i use RAW instead of form-data, with something like {"file":"C:/my_dir/imagem_01.jpg"} it doesn´t work.
I mean, the WS is executed without error, but the response is not what it should be.
In the PLSQL arena i've tried this (code snipet), but the result is the same, it executes but the result is not what it shoud be:
DECLARE
l_buffer RAW(32767);
l_amount INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len PLS_INTEGER;
BEGIN
/* p_file is the file to upload as a BLOB parameter */
IF p_file IS NOT NULL THEN
BEGIN
l\_blob\_len := dbms\_lob.getlength(p\_file);
utl\_http.set\_header(v\_req, 'Content-Type', 'application/octet-stream'); -- v\_req is a parameter
utl\_http.set\_header(v\_req, 'Content-Length', l\_blob\_len);
-- Read chunks of the BLOB and write the image into the Request
WHILE l\_pos \< l\_blob\_len LOOP
dbms\_lob.read(p\_file, l\_amount, l\_pos, l\_buffer);
utl\_http.write\_raw(v\_req, l\_buffer);
l\_pos := l\_pos + l\_amount;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
p\_err := SQLCODE;
p\_msg := 'ERROR: ' || SQLERRM;
END;
END IF;
END;
Any help would be greatly appreciated.
Rodrigo Coutinho
Portugal