mortenbra / alexandria-plsql-utils

Oracle PL/SQL Utility Library
778 stars 316 forks source link

Add HTTPS support to AWS S3 #4

Closed tschf closed 6 years ago

tschf commented 9 years ago

Just migrating the issue that I logged on google code: https://code.google.com/p/plsql-utils/issues/detail?id=25 to add https support to the S3 package.

mortenbra commented 9 years ago

I'd like to propose a slight modification to the implementation: Instead of having separate procedures to set the wallet path and wallet password, I'd like just a single procedure called set_wallet (p_wallet_path, p_wallet_password). This would be more consistent with utl_http itself, as well as several other (as yet unpublished) packages that will be included in the library.

mortenbra commented 9 years ago

Also, the g_use_https variable is set to true by default... but shouldn't this be false by default, and be set to true when (and if) the user calls set_wallet() ?

tschf commented 9 years ago

Currently, to get generated links in HTTPS also means calling set_wallet. For reports in APEX, set_wallet would need to be called somewhere before the report is called. I thought it seemed a little unnecessary to call set_wallet in this instance.

select amazon_aws_s3_pkg.get_download_url(file_ref, sysdate+1) download_link
from ...

Any preference for handling this case? Maybe a separate variable for the two scenarios? Or you are happy as is?

mortenbra commented 9 years ago

What about adding a p_protocol parameter to get_download_url (and also get_url), which can then be used to specify either "https" or "http" (the default), with the return value adjusted as necessary.

tschf commented 9 years ago

Sorry for the delay in getting back to this. Added p_protocol parameter as per your suggestion. Tested with new_object and get_download_url, but don't have any particular usages to test the more advanced functionality such as set_object_acl.

tschf commented 7 years ago

It's been quite some time on this, so just thought I'd see if there's any aspect you are unhappy with? Or if you'd rather implement it some other way, yourself?

I just merged with master to get rid of conflicts, and did a fresh test:

set serveroutput on

declare

    l_filerow files%rowtype;

begin

    DEBUG_PKG.debug_on;

    select *
    into l_filerow
    from files
    where id = 1;

    amazon_aws_s3_pkg.set_Wallet(
        p_wallet_path => 'file:/u01/app/oracle/product/12.1.0.2/db_1/owm/wallets/oracle',
        p_wallet_password => 'apassword'
    );

    amazon_aws_s3_pkg.new_object(
        p_bucket_name => 'tschf',
        p_key => 'file.jpg',
        p_object => l_filerow.dat,
        p_content_type => 'image/jpg',
        p_protocol => 'https'
    );

end;

Output

Compiling script: /home/trent/Projects/awsHttp/sample2.sql

07.12.2016 18:11:05: PUT https://tschf.s3.amazonaws.com/file.jpg

PL/SQL procedure successfully completed.

No errors.
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

Edit. Tested with just new_object at this stage