Skip to main content

Sample RESTful service

By the default, the plug-in uses sample ORDS RESTful service to upload, display, browse and delete uploaded images in the database. The RESTful service can be used to save uplaoded images in the database, filesystem or external file services.

A custom RESTful service

Any modifications to the sample RESTful service might be overridden in the future when updating plug-in to the most recent version. Because of that, we strongly recommend implementing your own RESTful service, for example as a copy of sample service. In guidelines section, you will find specification for a custom RESTful service compatible with Rich Text Editor Pro page item.

The plug-in sample RESTful service is created when the plug-in sample application supporting objects are installed or when installing the plug-in using DDL script. The sample RESTful services is used by the plug-in default configuration and the plug-in sample application. Uploaded images are stored in the plug-in sample table UC_FROALA_SAMPLE_CLOB_BLOBS.

The sample RESTful service implements templates described in the table below.

TemplateMethodDescription
browseGETTemplate is used to browse previously uploaded images stored in the database.
deletePOSTTemplate is used to delete images displayed in the Froala image browser.
get/:fileidGETTemplate displays uploaded images embedded in CLOB content.
uploadPOSTTemplate handles image upload using.
browseFolderGETAn example implementation showing image filtering using custom parameter folder.
uploadFolderPOSTAn example implementation of uploading images with a custom parameter folder.

Access token

The plug-in secures RESTful service request using the plug-in access token encoded using plug-in instance-specific salt string defined in the plug-in package UC_FROALA_SETTINGS. The encoded access token is available to all RESTful handlers through default query parameters. The access token is computed and encoded when Oracle APEX engine renders page item implementing the Rich Text Editor Pro.

When processing RESTful image request, a developer can decode the access token and get secured information about application session ID, given URL displaying uploaded images.

info

Using access token to secure RESTful service request is not mandatory but it's stricly recommended.

Salt string

The salt string is string definable in the plug-in package UC_FROALA_SETTINGS. The salt string is used to encode the access token and it should be changed after installing the plug-in.

Default query parameters

The plug-in RESTful service template handlers are invoked with additional default data send using query parameters. These query parameters can be used to identify application meta-data (session, id, page id, user) and uploaded image using PL/SQL bind variables.

Custom query parameters

Custom query parameters require extending sample RESTful handlers (we do not recommend it), or creating a custom RESTful service. A custom query parameters can be defined using the plug-in page item attribute Initialization JavaScript Code and image query parameter options (computed once on a page load) or using the supporting dynamic actions Upload Parameters and Image Browser Parameters.

By the default, the plug-in uses default query parameters described in the table below.

Parameter NameBind variableData typeDescriptionUploadBrowseDelete
accessToken:accessTokenVARCHAR2A current encoded access token.✔️✔️✔️
sessionId:sessionIdVARCHAR2A current APEX session ID.✔️✔️✔️
applicationId:applicationIdVARCHAR2A current application ID.✔️✔️✔️
pageId:pageIdVARCHAR2A current application page ID✔️✔️✔️
appUser:appUserVARCHAR2A current application username.✔️✔️✔️
filename:filenameVARCHAR2An image filename is available only when an image is dragged and dropped from the desktop.✔️
tempUniqueId:tempUniqueIdVARCHAR2An image temporary ID assigned by the plug-in.✔️
imageId:imageIdVARCHAR2An image ID in the database.✔️

Sample Templates

The plug-in sample RESTful service implements REST templates enabling the plug-in to work right after installation. These templates are also used by the plug-in sample application to showcase plug-in features. We do not recommend using the sample RESTful service in production enviroment wihout inspecting the code and changing the salt string.

upload

The sample upload template uses POST handler to accept uploaded file and save it in the sample application database table UC_FROALA_SAMPLE_CLOB_BLOBS.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI Templateupload
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/upload
Handler MethodPOST
Source TypePL/SQL
Mime Types AllowedNot defined

get/:fileid

The plug-in sample template displaying uploaded images uses GET handler to fetch an image from the sample application table UC_FROALA_SAMPLE_CLOB_BLOBS and streams it's content to a browser buffer.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI Templateget/:fileid
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/get/:fileid
MethodGET
Source TypePL/SQL
Mime Types AllowedNot defined

browse

The sample browse template uses GET handler to fetch uploaded images from the sample application table UC_FROALA_SAMPLE_CLOB_BLOBS and present them to the end-user using the rich text editor image browser.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI Templatebrowse
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/browse
MethodGET
Source TypePL/SQL
Mime Types Allowed

delete

The sample delete template uses POST handler deleting an image in the database sample table UC_FROALA_SAMPLE_CLOB_BLOBS.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI Templatedelete
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/delete
MethodPOST
Source TypePL/SQL
Mime Types Allowed

Sample application templates

The sample application templates uploadFolder and browseFolder are used exclusively by the plug-in sample application to showcase the plug-in dynamic actions Uplaod parameters and Image Browser Parameters.

live demo

Both dynamic action can be tested online in the sample application example page Image Upload Parameters.

These handlers uses the custom query parameter named folder. The value is computed based on page item value (select list), and is used to save the value along with an image in the table UC_FROALA_SAMPLE_CLOB_BLOBS as value for column FOLDER. When the plug-in image browser is invoked, the folder query parameter (page item value) is used computed again, and it is used to filter only images with column FOLDER matching the page item value.

info

These templates are copies of sample templates uplaod and browse, except they reference folder using :folder bind variable.

uploadFolder

The handler uses the custom query parameter folder to save the page item current value in the table UC_FROALA_SAMPLE_CLOB_BLOBS.FOLDER column.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI TemplateuploadFolder
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/uploadFolder
Handler MethodPOST
Source TypePL/SQL
Mime Types AllowedNot defined

browseFolder

The handler uses the custom query parameter folder to list uploaded and saved images in the sample application table UC_FROALA_SAMPLE_CLOB_BLOBS using SQL condition WHERE folder = :folder when the plug-in image browser is invoked.

Attribute
RESTful Service ModuleRich Text Editor Pro Sample REST
Module Base Path/ucfroalasamplerest/
URI TemplatebrowseFolder
Full URLhttps://example-domain.com/ords/RTE/ucfroalasamplerest/browseFolder
MethodGET
Source TypePL/SQL
Mime Types Allowed