Hi
The AWS nodes "Amazon S3" and Amazon S3 out" can support a bucket name provided as the msg.bucket property. It works fine but as the form specify that the bucket field in the form is required, a warning is generated on each deploy.
I propose a PR to change those 2 descriptors from:
bucket: {required:true},
to
bucket: {value:""},
in
<input type="text" id="node-input-name" data-i18n="[placeholder]aws.placeholder.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('amazon s3',{
category: 'storage-output',
color:"#C0DEED",
defaults: {
aws: {type:"aws-config",required:true},
bucket: {required:true},
filename: {value:""},
region: {value:"", required:true},
name: {value:""},
},
inputs:1,
outputs:1,
icon: "amazon.png",
align: "right",
label: function() {
return this.bucket ? "s3 "+this.bucket : "s3";
and
<input type="text" id="node-input-name" data-i18n="[placeholder]aws.placeholder.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('amazon s3 in',{
category: 'storage-input',
color:"#C0DEED",
defaults: {
aws: {type:"aws-config",required:true},
bucket: {required:true},
region: {value:"", required:true},
filepattern: {value:""},
name: {value:""},
},
inputs:0,
outputs:1,
icon: "amazon.png",
label: function() {
return this.bucket ? "s3 "+this.bucket : "s3";
}
I'm ready to send the PR if you are ok
Just for your reference, the JS code is perfectly handling that:
this.filename = n.filename || "";
var node = this;
var AWS = this.awsConfig ? this.awsConfig.AWS : null;
if (!AWS) {
node.warn(RED._("aws.warn.missing-credentials"));
return;
}
var s3 = new AWS.S3({"region": node.region});
node.on("input", function(msg) {
var bucket = node.bucket || msg.bucket;
if (bucket === "") {
node.error(RED._("aws.error.no-bucket-specified"),msg);
return;
}
var filename = node.filename || msg.filename;
if (filename === "") {
node.warn("No filename");
node.error(RED._("aws.error.no-filename-specified"),msg);
return;
}
and
node.status({fill:"blue",shape:"dot",text:"aws.status.checking-credentials"});
s3.listObjects({ Bucket: node.bucket }, function(err) {
if (err) {
node.warn(err);
node.error(RED._("aws.error.aws-s3-error",{err:err}));
node.status({fill:"red",shape:"ring",text:"aws.status.error"});
return;
}
node.status({});
node.on("input", function(msg) {
var bucket = node.bucket || msg.bucket;
if (bucket === "") {
node.error(RED._("aws.error.no-bucket-specified"),msg);
return;
}
var filename = node.filename || msg.filename;
if (filename === "") {
node.error(RED._("aws.error.no-filename-specified"),msg);
return;
}
var localFilename = node.localFilename || msg.localFilename;
Thanks
Published as v0.2.3. Thanks
system
Closed
23 January 2023 12:29
6
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.