mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-23 02:34:53 +00:00
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
This commit is contained in:
36
plugins/tiddlywiki/aws/modules/utils.js
Normal file
36
plugins/tiddlywiki/aws/modules/utils.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/*\
|
||||
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;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user