The following code demonstrates uploading data to Amazon S3 via the REST API signed with Amazon Signature Version 4:
(function() { var data = "Test"; var headers = { "Content-Type": "text/plain" }; net("PUT", "https://aBucketName.s3.amazonaws.com/fileName.txt", headers, data, use("aws4"), function(resp) { response.end(resp.status); }); }());
The following code demonstrates downloading data from Amazon S3 via the REST API signed with Amazon Signature Version 4:
(function() { net("GET", "https://aBucketName.s3.amazonaws.com/fileName.txt", use("aws4"), function(resp) { try { if (resp.status === 200) { response.write(resp.responseText); } response.end(resp.status); } catch (err) { response.end(err); } }); }());