node-red-contrib-file-manager
Version:
Handle File System
156 lines (145 loc) • 4.78 kB
HTML
<script type="text/javascript">
RED.nodes.registerType("fm-save-file", {
category: "file manager",
color: "#C7E9C0",
defaults: {
name: { value: "" },
filePath: { value: "" },
},
inputs: 1,
outputs: 1,
paletteLabel: "fm-save-file",
icon: "file.png",
label: function () {
return this.name || "fm-save-file";
},
oneditprepare: function () {
if (!this.pathType) {
this.pathType = "str";
}
$("#node-input-filePath").typedInput({
default: "str",
types: ["str", "msg", "flow", "global", "env"],
typeField: $("#node-input-pathType"),
});
},
});
</script>
<script type="text/html" data-template-name="fm-save-file">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-input-filePath"><i class="fa fa-folder"></i> Path</label>
<input
type="text"
id="node-input-filePath"
placeholder="File save path"
style="width:250px;"
/>
<input type="hidden" id="node-input-pathType" />
</div>
</script>
<script type="text/html" data-help-name="fm-save-file">
<p>Save Uploaded File in Local Folder</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>
name
<span class="property-type">string</span>
</dt>
<dd>Name of node to be displayed in editor</dd>
<dt>path<span class="property-type">string</span></dt>
<dd>Destionation of the file path example: /file</dd>
<dt>file<span class="property-type">string</span></dt>
<dd>
File Buffer object <br /><b>Example:</b><br />
msg.file = Buffer.from(msg.req.files[0].buffer,"base64");<br />
msg.path = "/public/files/"+ msg.req.files[0].originalname;<br />
return msg;
</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<p>It will return file path</p>
</dl>
<h3>Details</h3>
<p>Create a new file from Buffer string and save into local folder</p>
</script>
<!--M-->
<script type="text/javascript">
RED.nodes.registerType("fm-move-file", {
category: "file manager",
color: "#C7E9C0",
defaults: {
movename: { value: "" },
sourcePath: { value: "" },
destinationPath: { value: "" },
},
inputs: 1,
outputs: 1,
paletteLabel: "fm-move-file",
icon: "file.png",
label: function () {
return this.movename || "fm-move-file";
},
oneditprepare: function () {
if (!this.sourcePathType) {
this.sourcePathType = "str";
}
if (!this.destinationPathType) {
this.destinationPathType = "str";
}
$("#node-input-sourcePath").typedInput({
default: "str",
types: ["str", "msg", "flow", "global", "env"],
typeField: $("#node-input-sourcePathType"),
});
$("#node-input-destinationPath").typedInput({
default: "str",
types: ["str", "msg", "flow", "global", "env"],
typeField: $("#node-input-destinationPathType"),
});
},
});
</script>
<script type="text/html" data-template-name="fm-move-file">
<div class="form-row">
<label for="node-input-movename"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-movename" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-input-sourcePath"><i class="fa fa-tag"></i> Source</label>
<input type="text" id="node-input-sourcePath" placeholder="Source Path" />
<input type="hidden" id="node-input-sourcePathType" />
</div>
<div class="form-row">
<label for="node-input-destinationPath"
><i class="fa fa-tag"></i> Destination</label
>
<input
type="text"
id="node-input-destinationPath"
placeholder="Destination Path"
/>
<input type="hidden" id="node-input-destinationPathType" />
</div>
</script>
<script type="text/html" data-help-name="fm-move-file">
<p>Move File in Different Location</p>
<h3>Properties</h3>
<dl class="message-properties">
<dt>name
<span class="property-type">string</span>
</dt>
<dd>Name of node to be displayed in editor</dd>
<dt>sourcePath<span class="property-type">string</span></dt>
<dd>Source file path example: /file/abc.jpg</dd>
<dt>destinationPath<span class="property-type">string</span></dt>
<dd>Destionation file path example: /file2/abc.jpg</dd>
</dl>
</dl>
<h3>Details</h3>
<p>Move File in Different Location</p>
</script>