Get Images from ORACLE REST Web Service

Share on:

How to get Images from ORACLE REST Web Service ?

Preview Oracle REST APIs provides the feature of media resource, here we can write the query with two columns content type and image blob.

While i was trying to implement i saw tweaks, the query has to be in below format only.

1SELECT 'content_type',
2 column 
3 FROM . . .[TABLE]

So now we need one table holding images with their format types and rest enabled APEX environment.

1SELECT mimetype, product_image 
2FROM  demo_product_info
3WHERE  product_id= :product_id;

NOTE: Content type must be first column.

Table structure:

 1 CREATE TABLE  "DEMO_PRODUCT_INFO"
 2   ( "PRODUCT_ID" NUMBER NOT NULL ENABLE,
 3 "PRODUCT_NAME" VARCHAR2(50),
 4 "PRODUCT_DESCRIPTION" VARCHAR2(2000),
 5 "PRODUCT_IMAGE" BLOB,
 6 "MIMETYPE" VARCHAR2(255),
 7 "FILENAME" VARCHAR2(400),
 8 "IMAGE_LAST_UPDATE" TIMESTAMP (6) WITH LOCAL TIME ZONE,
 9 "TAGS" VARCHAR2(4000),
10  CONSTRAINT "DEMO_PRODUCT_INFO_PK" PRIMARY KEY ("PRODUCT_ID")
11  USING INDEX  ENABLE,
12  CONSTRAINT "DEMO_PRODUCT_INFO_UK" UNIQUE ("PRODUCT_NAME")
13  USING INDEX  ENABLE
14   )
15/

API Setup.

  • Create module for the API. Preview
  • Create Template Preview
  • Create GET Handler. Preview
  • Create Parameter for product_id. Preview

Try url:
https://apex.oracle.com/pls/apex/ashish_portfolio/image_id?product_id=100
https://apex.oracle.com/pls/apex/doctor_app/img/image/81

You might Also like: