Code Monkey home page Code Monkey logo

s3hook's Introduction

S3 Hook

Transparent (via XHook), Cross-domain (via XDomain), Client-side S3 Request Signing

All requests sent to s3.amazonaws.com are modified to include the correct Authorization header for the given credentials. s3-ap-southeast-2.amazonaws.com is also supported. To use other S3 endpoints or custom domains, see API for usage of the proxy function.

Disclaimer

As this library self signs its own requests, it requires the access key and the secret key. For this reason, it should only be used for internal applications where the keys are only provided to trusted users, or in cases where a key pair is provided by the user and never sent to the server. For additional security, a policy for the given key pair should be created to restrict access to a particular bucket and to a particular prefix.

Features

Example

//enable hook
s3hook.set("AKIAIOSFODNN7EXAMPLE","k3nL7gH3+PadhTEVn5EXAMPLE");

//choose your favourite XHR library, jQuery for example...
//then just use the AWS REST API...

//get bucket object list
$.get('https://s3.amazonaws.com/jpillora-usa/')

//put an object
$.ajax({type:'PUT', url:'https://s3.amazonaws.com/jpillora-usa/foo.txt', data:'hello world!' });

Tip: Set the x-amz-acl: public-read header to make an object public

Demo

Download

API

s3hook.set(access, secret)

Enable S3 Hook with the provided credentials

s3hook.clear()

Disable S3 Hook and clear credentials

s3hook.xml2json

Default true

Convert all XML responses (*/xml) to JSON (application/json)

s3hook.proxy(url)

Add a new XDomain slave by providing a URL to a proxy.html file

S3 Hook is initialised with:

  • https://s3.amazonaws.com/jpillora-usa/xdomain/proxy.html
  • https://s3-ap-southeast-2.amazonaws.com/jpillora-aus/xdomain/proxy.html

So, to add your own, create a https://MY-BUCKET.s3.amazonaws.com/MY/PATH/proxy.html:

<!DOCTYPE HTML>
<script src="http://s3.amazonaws.com/jpillora-usa/xdomain/0.6.min.js" master="*"></script>

Then add it:

s3hook.proxy("https://MY-BUCKET.s3.amazonaws.com/MY/PATH/proxy.html")

Now, cross-domain requests to https://MY-BUCKET.s3.amazonaws.com will work

References

http://docs.aws.amazon.com/AmazonS3/latest/API/APIRest.html

http://docs.aws.amazon.com/AmazonS3/latest/dev/MakingRequests.html

http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html

Contributing

See CONTRIBUTING.md

Todo

  • Create a better S3 client than the AWS Console

MIT License

Copyright © 2013 Jaime Pillora <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

s3hook's People

Contributors

jpillora avatar

Stargazers

Toba Oluyide avatar

Watchers

Toba Oluyide avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.