Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Build a Web Service to Up and Download Files for Oracle Database

815 views

Published on

Using just SQL and PL/SQL with Oracle REST Data Services, I'll show you how to build a REST API to POST and GET files to and from your Oracle Database.

The files are stored in a table as BLOBs.

The sample code found here:
Using just SQL and PL/SQL with Oracle REST Data Services, I'll show you how to build a REST API to POST and GET files to and from your Oracle Database.

The files are stored in a table as BLOBs.

The sample code and slides can be found here:
https://www.thatjeffsmith.com/archive/2018/11/building-a-web-service-for-uploading-and-downloading-files-the-video/

Video on YouTube:
https://www.youtube.com/watchv=n9xy0GF1TYc&feature=youtu.be

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Build a Web Service to Up and Download Files for Oracle Database

  1. 1. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | ORDSFile Up/Downloads via REST https://oracle.com/rest Jeff Smith Senior Principal Product Manager Jeff.d.smith@oracle.com || @thatjeffsmith Database Tools, Oracle Corp
  2. 2. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Oracle REST Data Services 2 Formerly Known as the APEX Listener
  3. 3. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | • Model resources, not actions: – GET /ords/hr/employees/ - GOOD – GET /ords/hr/delete_emp/ - BAD – DELETE /ords/hr/employees/97 - GOOD • Uniform operations on all resources: – GET, POST, PUT, DELETE, OPTIONS, HEAD • Stateless requests, state transitions communicated via hyper-links. The Architectural Style of the Web{REST}
  4. 4. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | • Java JEE mid tier application, e.g., WebLogic, Tomcat, Glassfish (deprecated) – Also supported “Standalone” mode • For input, maps/binds URI to SQL and PL/SQL • For output, transforms results to JSON and other formats Oracle REST Data ServicesHTTP(S) client Oracle Database SQLMap & BindURI JSON Transform to JSON SQL Result Set How do we apply this Architectural Style to a DB?
  5. 5. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | https://host/ords/human/peeps/10 SELECT … WHERE EMPLOYEE_ID = :id Oracle DB 1. Browser GET request 2. Proxy connect HR, executes ‘peeps’ HANDLER code ORDS Runs in WLS, Tomcat, or as a standalone process Oracle REST Data Services Anatomy of a RESTful Service Transaction
  6. 6. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Typical Deployments • Standard webserver layout • Implements Java Servlet • Deploys to WLS, Tomcat, Glassfish • or Standalone (embedded Jetty) WLS,Tomcat ORDS Apache Static Files -HTML, CSS, JS /hr/emp JSON Binary HTML … HTTP(s) Results JDBC
  7. 7. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | And it’s Easy! I had been looking for a chance to perform a POC, so I proposed I just provide him with a couple of web services. In under a day I had functioning web services in place for him to consume. There’s been refinements to them and new ones developed since then. We are now exploring where else we could leverage this technology. - a REAL customer talking about ORDS
  8. 8. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Today’s Mission – Get Files into a BLOB GET & POST => https://
  9. 9. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Our Resource Templates • media/ – GET retrieves a list of files with links – POST adds a new file • media/:id – GET retrieves file info with link to content • media/:id/content – GET downloads content of the file
  10. 10. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Handler Code – it’s all SQL & PL/SQL!
  11. 11. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | POST – Adding a File
  12. 12. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | GET – File Details
  13. 13. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | GET – ‘Download’ the File
  14. 14. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | The Code…is All on My Blog • I provide: – The TABLE – The REST Services Module • You provide: – The Database – ORDS running – Files you want to play with https://www.thatjeffsmith.com – click on ORDS
  15. 15. Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Swagger Doc http://localhost:8080/ords/hr/open-api-catalog/ora_magazine/
  16. 16. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Thanks! Questions? Resources • Blogs • Videos • GitHub Examples • Articles – UKOUG Scene Why REST, and What’s in it or Me? – Oracle Mag AUTO REST & REST Enabled SQL

×