Requirement:
File Data present in tables as BLOB. A rest service should be exposed to download the file content from browser in Oracle Service Bus OSB.
Table structure
CREATE TABLE X
( XNO NUMBER, --id
COLUMN1 BLOB, --file
COLUMN2 TIMESTAMP (6),
COLUMN3 VARCHAR2(200 BYTE), --filename
COLUMN4 VARCHAR2(500 BYTE) --version
)
Example url : https://host:port/OrigDocFetchService/ProxyService?id=1&documentName=Overview1.pdf&version=1.0
How it is implemented::
The proxy first receives the request and identifies the content type based on the documentname passed in the query parameters.
Then it fetches the content from Database via DB Adapter. (Please read documentation on how to configure db adapter which links db via datasource in weblogic)
Once Document is fetched from DB then we have a helper function DataSource decode64ToStream(String) to help convert the base64 encoded value which OSB gives from DB to a stream which browser can act on.
Then the Content-Type and disposition tags Content-Disposition are set as below
Content-Type = $contentType example 'application/pdf;' for pdf or 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' for docx content
(Please refer https://technet.microsoft.com/en-us/library/ee309278(office.12).aspx)
Content-Disposition = concat("inline; filename=""",$inbound/ctx:transport/ctx:request/http:query-parameters/http:parameter[@name='documentName']/@value,"""")
example "inline: filename: "Overview1.pdf""
Once these headers are set and binary stream flowing back to browser as body then the browser will be in a position to download the content.
The full java helper functions and OSB project can be available at below github repository.
https://github.com/praveencasimir/DownloadBLOBSBProject
File Data present in tables as BLOB. A rest service should be exposed to download the file content from browser in Oracle Service Bus OSB.
Table structure
CREATE TABLE X
( XNO NUMBER, --id
COLUMN1 BLOB, --file
COLUMN2 TIMESTAMP (6),
COLUMN3 VARCHAR2(200 BYTE), --filename
COLUMN4 VARCHAR2(500 BYTE) --version
)
Example url : https://host:port/OrigDocFetchService/ProxyService?id=1&documentName=Overview1.pdf&version=1.0
How it is implemented::
The proxy first receives the request and identifies the content type based on the documentname passed in the query parameters.
Then it fetches the content from Database via DB Adapter. (Please read documentation on how to configure db adapter which links db via datasource in weblogic)
Once Document is fetched from DB then we have a helper function DataSource decode64ToStream(String) to help convert the base64 encoded value which OSB gives from DB to a stream which browser can act on.
Then the Content-Type and disposition tags Content-Disposition are set as below
Content-Type = $contentType example 'application/pdf;' for pdf or 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' for docx content
(Please refer https://technet.microsoft.com/en-us/library/ee309278(office.12).aspx)
Content-Disposition = concat("inline; filename=""",$inbound/ctx:transport/ctx:request/http:query-parameters/http:parameter[@name='documentName']/@value,"""")
example "inline: filename: "Overview1.pdf""
Once these headers are set and binary stream flowing back to browser as body then the browser will be in a position to download the content.
The full java helper functions and OSB project can be available at below github repository.
https://github.com/praveencasimir/DownloadBLOBSBProject