Skip to main content

Template handler displaying image

This document covers sample implementations for template GET handler displaying uploaded images in the plug-in built-in image browser. All examples displays images from the plug-in table UC_FROALA_SAMPLE_BLOBS. The difference between handlers is complexity of PL/SQL code, whether handler uses default query parameters, custom parameters or uses image checksum to secure display handler.

handler features
  • can be combined with handler uploading an image Simple
  • can be combined with handler displaying an image Simple
  • doesn't use default parameters and the URL to displaying image handler (page item attribute Image GET URL) is hardcoded in the code

Requirements

Handler displaying uploaded image must meet the following requirements:

  1. must use GET method
  2. must be compilable at the run time
  3. must return 200 HTTP status
  4. must print array of JSON objects describing images

Handler definition

AttributeValue
RESTful Service ModuleA custom RESTservice
Module Base Path/customrest/
URI Templatebrowse-simple
Full URLhttps://example-domain.com/ords/workspacename/customrest/browse-simple
Handler MethodGET
Source TypePL/SQL
Mime Types AllowedNot defined

Handler parameters

The browse handler doesn't require registering resource parameters as long as REST specific bind variable :status_code is used to set request HTTP status.

Handler Source

declare
v_sys_refcursor sys_refcursor;
v_url varchar2(4000);
begin
v_url := 'https://example-domain.com/ords/workspacename/customrest/display/';

open v_sys_refcursor for
select
v_url||id as "url"
from
UC_FROALA_SAMPLE_BLOBS
;

apex_json.write( v_sys_refcursor );

:status_code := 200;

exception
when others then
:status_code := 500;

apex_json.open_object;
apex_json.write('error', SQLERRM);
apex_json.close_object;
end;

Handler Output

The handler output must be Array of JSON objects describing uploaded images with property url.

List of images for image browser
[
{ "url":"https://example-domain.com/ords/workspacename/customrest/display-simple/29774" },
{ "url":"https://example-domain.com/ords/workspacename/customrest/display-simple/29775" },
{ "url":"https://example-domain.com/ords/workspacename/customrest/display-simple/29776" }
]

Error handling

The plug-in display browse images error as APEX inline page notification error.