1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-24 00:50:28 +00:00

AWS Plugin: Add savetype for s3-savetiddler(s) command

This commit is contained in:
Jermolene 2017-08-23 10:31:28 +01:00
parent b6f948b61e
commit 94f9929c80
2 changed files with 8 additions and 4 deletions

View File

@ -28,7 +28,7 @@ The content in the files is deserialized according to the content type reported
Save a raw tiddler to a file in an S3 bucket.
```
--aws s3-savetiddler <title> <region> <bucket> <filename> <zipfilename>
--aws s3-savetiddler <title> <region> <bucket> <filename> <zipfilename> <savetype>
```
* ''title'': title of the tiddler to save
@ -36,19 +36,21 @@ Save a raw tiddler to a file in an S3 bucket.
* ''bucket'': name of the bucket to save the saved file
* ''filename'': filename of the saved file
* ''zipfilename'': optional; the file will be packed into a ZIP file with the specified name
* ''savetype'': optional; the MIME type for the saved file (defaults to ''type'' or "text/html")
! "s3-savetiddlers" subcommand
Save raw tiddlers matching a filter to an S3 bucket.
```
--aws s3-savetiddlers <filter> <region> <bucket> <prefix>
--aws s3-savetiddlers <filter> <region> <bucket> <prefix> <savetype>
```
* ''filter'': filter identifying tiddlers to render
* ''region'': AWS region
* ''bucket'': name of the bucket to save the files
* ''prefix'': prefix for rendered file names
* ''savetype'': optional; the MIME type for the saved file (defaults to ''type'' or "text/html")
! "s3-rendertiddler" subcommand

View File

@ -163,6 +163,7 @@ Command.prototype.subCommands["s3-savetiddler"] = function() {
bucket = this.params[3],
filename = this.params[4],
zipfilename = this.params[5],
saveType = this.params[6],
tiddler = wiki.getTiddler(title),
text = tiddler.fields.text,
type = tiddler.fields.type,
@ -182,7 +183,7 @@ Command.prototype.subCommands["s3-savetiddler"] = function() {
}
// Save the file
async.series([
awsUtils.putFile.bind(null,region,bucket,filename,text,type)
awsUtils.putFile.bind(null,region,bucket,filename,text,saveType || type)
],
function(err,results){
self.callback(err,results);
@ -198,6 +199,7 @@ Command.prototype.subCommands["s3-savetiddlers"] = function() {
region = this.params[2],
bucket = this.params[3],
prefix = this.params[4],
saveType = this.params[5],
tiddlers = wiki.filterTiddlers(filter);
// Check parameters
if(!filter || !region || !bucket || !prefix) {
@ -210,7 +212,7 @@ Command.prototype.subCommands["s3-savetiddlers"] = function() {
var tiddler = wiki.getTiddler(title),
text = tiddler.fields.text || "",
type = tiddler.fields.type || "text/vnd.tiddlywiki";
awsUtils.putFile(region,bucket,prefix + encodeURIComponent(title),text,type,callback);
awsUtils.putFile(region,bucket,prefix + encodeURIComponent(title),text,saveType || type,callback);
},
function(err,results) {
self.callback(err,results);