Monday, January 3, 2011

Building an Amazon S3 Client with Application Express 4.0 White Paper Available


If you have seen me present about web services and Oracle Application Express 4.0 in the last year (at APEXposed, OOW, or ODTUG Kaleidoscope), you have probably heard me say that a white paper about building an Amazon S3 client with APEX was forthcoming. I am happy to announce the paper is now available along with a corresponding sample application. The best part is with the AWS Free Usage Tier, you can try everything out for free!

15 comments:

Anonymous said...

Hi Jason,

Thank you for this. This is exactly the guide and examples that we were looking for.

Regards,
Ben

Anonymous said...

Hi

Do you know where I can find material to tweak Oracle DB and have wallet configured because I am getting this:
ORA-20001: The webservice was unreachable because either the URL you supplied was invalid, your environment requires a valid proxy server address for HTTP requests, or a wallet needs to be configured for HTTPS requests.

Thank you.
Shaun

Jason Straub said...

Shaun:

I assume the resource you are requesting is https? If so, then you use owm to configure a wallet on the database.

http://download.oracle.com/docs/cd/E11882_01/network.112/e10746/asowalet.htm#ASOAG9728

Then you configure Application Express to use that wallet:

http://download.oracle.com/docs/cd/E17556_01/doc/admin.40/e15521/adm_mg_service_set.htm#BABHEHAG

Hope that helps.

Regards,

Jason

Morten Braten said...

Hi Jason, based on your white paper I created a stand-alone PL/SQL API for S3 that makes it even easier to work with S3 from Apex and other PL/SQL applications.

Read more about it here:

http://ora-00001.blogspot.com/2011/03/amazon-s3-api-for-plsql.html

And thanks for the excellent white paper that got me started! :-)

- Morten

Anonymous said...

Jason, I've got the same problem - "ORA-20001: The webservice was unreachable because either the URL you supplied was invalid, your environment requires a valid proxy server address for HTTP requests, or a wallet needs to be configured for HTTPS requests."

I'm trying it on 11gR2 XE beta version, however. I don't seem to use wrong URL and network connectivity to s3.amazonaws.com work s as verified from the command line.

I followed up your links about wallets and I can't figure out how to create it on Linux for 11gR2 XE beta. In fact, the documentation is for Advanced Security option which is licensed separately.

So do I have a problem with the wallet indeed and do I really need to license Advanced Security option to create a wallet?

Anonymous said...

OK. The APEX error was misleading and I suspected it might just be new 11g ACL. Indeed, this fixed the problem - http://download.oracle.com/docs/cd/E17556_01/doc/install.40/e15513/otn_install.htm#BABBHCID

Anonymous said...

Finally, everything worked beautifully. I lost some time with a problem when creating a bucket failed silently. Turned out such bucket names already existed but took a while to troubleshoot.

Thus, a question - Jason, do you have any recommendations on how to handle errors from AWS REST API?

And another question, looks like AWS provides SOAP web-services with proper WSDL. Wouldn't it be easier to use it from APEX by simply pointing to WSDL service description and viola - you have complete interface.

Michelle Skamene said...

Hi Jason,
Very helpful post and White Paper, thank you!
I am on a hosted environment, and do not have access to configure the Application Express instance for wallet. Can I use utl_http.set_wallet? Where would I do this if I am setting up a REST Web Service Reference under 4.1?
Thank you very much for any help you can provide. I am trying to access a number of book-related APIs (Google Books API, as an example).
Best,
Michelle

Jason Straub said...

Michelle,

Unfortunately you need to have access to the actual wallet on the file-system even to use utl_http.set_wallet. That will not actually create the wallet. The only recourse you have is to ask the hosting providing to create a generic wallet and configure it in Instance Settings.

Regards,

Jason

Anonymous said...

I have files with size range from 10MB-50GB, can this be handled by this solution?

Jason Straub said...

Fadi:

Technically, the only limiter would be the timeout defined by the web server used for your Application Express instance. So it should be possible. However, with file sizes that large, you may want a client that can pause, and restart upload/download, which would not be supported by this client.

Regards,

Jason

Unknown said...

Hi!

I installed your amazon_s3_installer.sql, and page 1 (buckets) works fine. It shows the listing of all buckets. However, pages 2 to 4 doesn't work as expected. What could be wrong?

For example, in page 3 (List Bucket Contents), when I choose any bucket in page1, it gets redirected to page 3 (as expected) and always show the message 'no data found', even though there are files in all directories. It can be verified that the files are present thru S3fox. Also when I try out page 4 (Create Object) in APEX, after I submit the file, it shows 'Object added' message, but when checking in S3fox, no new object was added.

By the way, I am using the same id and secret key in both APEX and S3fox.

Thanks.
KZ

Jason Straub said...

KZ:

I recently helped a colleague that was having a similar issue. It seems that in some instances, S3 doesn't let you call the bucket like:

http://s3.amazonaws.com/bucketname

It wants to be called like:

http://bucketname.s3.amazonaws.com

Try changing the Web reference to use that URL. That might also change the string to sign that you pass to return amazon_signature_sh1.

If that doesn't work, use a local proxy like ProxyTrace and run your requests through it. You will see the message returned from Amazon. You can also click the session link at the bottom of the page and examine the contents of the collection. If the contents are truncated, simply write a query to show everything in the clob001 column.

Regards,

Jason

Hawk said...

Hi,

I know this is too old. But so many websites referring to it. So I believe many others will benefit from what I'd share here.

First, Thank you very much for such a detailed explanation of implementing this.
I just want to point out, that I had the same problem KZ had. I Could list the buckets. But I get 'HTTP error' when I try to list the bucket contents.

So I followed your advice of changing the URL to 'http://bucketname.s3.amazonaws.com', and the error was gone. However, I was still getting 'No data found'.

I spent two days trying to figure that out. I checked the session, where the collection returned the notorious error 'The request signature we calculated does not match the signature you provided. Check your key and signing method'.

Finally, I found the solution here 'http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html' under 'Example List', the solution was in the note:
Note the trailing slash on the CanonicalizedResource and the absence of query string parameters. .

I added slash to the end of my to the end of my Authorization parameter to be like this:

return driver_aws.amazon_signature_sh1('GET'||chr(10)||chr(10)||chr(10)||:S3_DATE_TIME||chr(10)||'/'||:P210_NAME||'/');

And it worked.

Thank you very much again.

Hawk

Jason Straub said...

Hi Hawk,

Thanks for sharing your tip!

Regards,

Jason