简体   繁体   中英

Access files on Amazon S3 using HTML5 / JavaScript

Is it possible to access the files on Amazon S3 using JavaScript / HTML5. I basically plan to access these files in a PhoneGap app.

To be more specific, I mean without any server in middle ie making direct calls to Amazon S3. Is it possible?

Yes. You can enable CORS for your bucket so that objects can be loaded via XMLHttpRequest .

When using PhoneGap/Cordova specifically, you may be able to bypass enabling CORS on the server by whitelisting the domain from within your app:

Answering my own question - I came up with a JavaScript S3 request signer using which I was able to sign the URL and access the files on S3 from JavaScript.

Anybody needs any details, please leave comment and would be happy to assist.

Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM