1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-04 03:03:18 +00:00
TiddlyWiki5/plugins/tiddlywiki/aws/modules/utils.js
Jermolene a346888213 Add first release of AWS plugin
Tools for working with Amazon Web Services:

* Templates for saving a TiddlyWiki as a single JavaScript file in a
ZIP file that can be executed as an AWS Lambda function. In this form,
TiddlyWiki is a self contained single file containing both code and
data, just like the standalone HTML file configuration
* Commands that can be used to interact with AWS services, under both
the Node.js and Lambda configurations of TiddlyWiki
2017-07-03 20:34:58 +01:00

37 lines
720 B
JavaScript

/*\
title: $:/plugins/tiddlywiki/aws/utils.js
type: application/javascript
module-type: library
AWS utility functions
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Put a file to an S3 bucket
*/
function putFile(region,bucketName,title,text,type,callback) {
console.log("Writing file",bucketName,title,type)
var AWS = require("aws-sdk"),
s3bucket = new AWS.S3({
region: region
}),
encoding = ($tw.config.contentTypeInfo[type] || {encoding: "utf8"}).encoding,
params = {
Bucket: bucketName,
Key: title,
Body: new Buffer(text,encoding),
ContentType: type || "text/plain"
};
s3bucket.upload(params,callback);
}
exports.putFile = putFile;
})();