Saving data to S3 using Javascript or jQuery

I want to collect data entered by a user in a browser and save it on Amazon S3. Is there something I can do with Javascript / JQuery?

+4
source share
5 answers

Yes, it is possible, and, as I already pointed out in the comments to the accepted answer, there are legitimate and useful applications for this without compromising security and credentials.

You can send objects to S3 directly from the browser: http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectPOST.html

+2
source

I know this is an old question, but I had the same problem, and I thought I found a solution. S3 has a REST interface to which you can directly send POST data without exposing your AWS secret key. This way you can create an AJAX POST request to the endpoint of the slave S3 using Javascript or jQuery. You can also specify an access policy in a request that restricts access to download to only certain buckets and certain directories.

Amazon authenticates your requests using the HMAC signature that you provided in the request. The signature is built using the information about the request and your AWS secret key that only you and Amazon know, so fraudulent requests cannot be made without someone who has a valid signature.

+8
source

Bad idea:

1) Think about how many fun people could empty your bank account when they find your S3 credentials embedded in your Javascript code.

2) javascript will be downloaded from your server and trying to talk to Amazon servers - this is prohibited as cross-domain communication.

You would like to process something like this on the server. You can easily crack the AJAX interface to send data to client browser -> your server -> amazon . Thus, your S3 credentials are stored on your server and are not transmitted by any means to everyone who uses your site.

+4
source

Maybe take a look at node.js and try the aws-sdk package:

 npm install aws-sdk 

There is a blog and doc that I found on how to upload files to S3:

this blog. and aws doc.

+1
source

There are many problems trying to access S3 through client code:

  • Unable to protect your credentials.
  • Many answers are in XML instead of JSON, and the XML parsing mechanism in JavaScript is heavy and slow.
  • Authentication of requests will require the implementation of JavaScript HMAC-SHA1.
  • There are problems with making cross-domain requests from JavaScript without routing through a proxy.

In general, there are currently no client-side JavaScript solutions available. If you're interested in server-side JavaScript, there are several S3 classes floating around GitHub for Node.js.

0
source

Source: https://habr.com/ru/post/1339403/


All Articles