-
Notifications
You must be signed in to change notification settings - Fork 33
/
ftp.html
executable file
·211 lines (198 loc) · 9.56 KB
/
ftp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!--
Copyright 2014 Atsushi Kojo.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="ftp">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-bookmark"></i> <span data-i18n="ftp.label.host"></span></label>
<input type="text" id="node-config-input-host" placeholder="localhost" style="width: 40%;" />
<label for="node-config-input-port" style="margin-left: 10px; width: 35px; "> <span data-i18n="ftp.label.port"></span></label>
<input type="text" id="node-config-input-port" placeholder="21" style="width:45px">
</div>
<div class="form-row">
<label for="node-config-input-user"><i class="fa fa-user"></i> <span data-i18n="ftp.label.user"></span></label>
<input type="text" id="node-config-input-user" placeholder="anonymous" />
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-lock"></i> <span data-i18n="ftp.label.password"></span></label>
<input type="password" id="node-config-input-password">
</div>
<div class="form-row">
<label for="node-config-input-connTimeout"><i class="fa fa-clock-o"></i> <span data-i18n="ftp.label.connTimeout"></span></label>
<input type="text" id="node-config-input-connTimeout" placeholder="10000">
</div>
<div class="form-row">
<label for="node-config-input-pasvTimeout"><i class="fa fa-clock-o"></i> <span data-i18n="ftp.label.pasvTimeout"></span></label>
<input type="text" id="node-config-input-pasvTimeout" placeholder="10000">
</div>
<div class="form-row">
<label for="node-config-input-keepalive"><i class="fa fa-clock-o"></i> <span data-i18n="ftp.label.keepalive"></span></label>
<input type="text" id="node-config-input-keepalive" placeholder="10000">
</div>
<div class="form-row">
<label for="node-input-secure"><i class="fa fa-key"></i> <span data-i18n="ftp.label.secure"></span></label>
<input type="checkbox" id="node-input-secure" placeholder="once" style="width: 10%; vertical-align: top;">
<label for="node-config-input-secureOptions" style="width: 20%; vertical-align: top;"> <span data-i18n="ftp.label.secureOptions"></span></label>
<input type="text" id="node-config-input-secureOptions" style="width: 35%; vertical-align: top;">
</div>
</script>
<script type="text/x-red" data-help-name="ftp">
<p>Configuration for a connection to an remote FTP server.</p>
<p></p>
<p><code>Host</code> is The hostname or IP address of the remote FTP server. Default: <code>localhost</code></p>
<p><code>Port</code> is The port of the remote FTP server. Default: <code>21</code></p>
<p><code>User</code> is Username for authentication. Default: <code>anonymous</code></p>
<p><code>Password</code> is Password for authentication. Required input.</p>
<p><code>Connection Timeout</code> is How long (in milliseconds) to wait for the control connection to be established. Default: <code>10000</code></p>
<p><code>PASV Timeout</code> is How long (in milliseconds) to wait for a PASV data connection to be established. Default: <code>10000</code></p>
<p><code>Keepalive</code> is How often (in milliseconds) to send a 'dummy' (NOOP) command to keep the connection alive. Default: <code>10000</code></p>
<p><code>Data connection encryption</code> is Set to true for both control and data connection encryption. Default: <code>false</code></p>
<p><code>Secure Options</code> is Additional options to be passed to tls.connect(). Default: (none)</p>
</script>
<script type="text/x-red" data-help-name="ftp in">
<p>Allows LIST, GET, PUT, APPEND, DELETE and MKDIR of files on a remote FTP server.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="optional">filename
<span class="property-type">string</span>
</dt>
<dd> the path/name of the file on the remote FTP server. </dd>
<dt class="optional">localFilename
<span class="property-type">string | buffer</span></dt>
<dd> the path/name of the file on the local machine.</dd>
</dl>
<h3>Outputs</h3>
<ol class="node-ports">
<li>Standard output (List)
<dl class="message-properties">
<dt>payload <span class="property-type">array</span></dt>
<dd>array of the file/folders in the user's default ftp folder</dd>
</dl>
</li>
<li>Standard output (Get, Put, Append, Delete and Mkdir)
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>Message that processing is complete.</dd>
</dl>
</li>
<li>Standard error
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>Error message.</dd>
</dl>
</li>
</ol>
<h3>Details</h3>
<p><code>msg.filename</code> is the path/name of the file on the remote FTP server</p>
<p><code>msg.localFilename</code> is the path/name or buffer of the file on the local machine</p>
<p>NOTE: the local machine is where NR is running - this might not be the machine where your browser connects to Node Red.</p>
<p></p>
<p>GET uses <code>msg.filename</code> and <code>msg.localFilename</code></p>
<p>PUT uses <code>msg.filename</code> and <code>msg.localFilename</code></p>
<p>APPEND uses <code>msg.filename</code> and <code>msg.localFilename</code></p>
<p>DELETE uses only <code>msg.filename</code></p>
<p>LIST uses <code>msg.filename</code>. Returns an array of the file/folders in the user's default ftp folder, containing type, name, sticky, rights(an object), acl, owner, group, size and date.</p>
<p>MKDIR uses <code>msg.filename</code> to specify the directory name. Recursive addition is allowed.</p>
<p></p>
<p>You can pass <code>msg.filename</code> and <code>msg.localFilename</code> to this node, however values entered in the node will take precedence.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('ftp', {
category: 'config',
color:"BurlyWood",
defaults: {
host: { value: '' },
port: { value: '' },
secure: { value: false },
secureOptions: { value: '' },
user: { value: '' },
connTimeout: { value: '' },
pasvTimeout: { value: '' },
keepalive: { value: '' }
},
credentials: {
password: { type: 'password', required: true },
},
label: function() {
return this.host
}
});
</script>
<script type="text/x-red" data-template-name="ftp in">
<div class="form-row">
<label for="node-input-ftp"><i class="fa fa-user"></i> Add new FTP Server</label>
<input type="text" id="node-input-ftp">
</div>
<div class="form-row">
<label for="node-input-operation"><i class="fa fa-wrench"></i> Operation</label>
<select type="text" id="node-input-operation">
<option value="list">list</option>
<option value="get">get</option>
<option value="put">put</option>
<option value="append">append</option>
<option value="delete">delete</option>
<option value="mkdir">mkdir</option>
</select>
</div>
<div class="form-row input-filename-row hidden">
<label for="node-input-filename"><i class="fa fa-file"></i> <span data-i18n="ftp_in.label.filename"></span></label>
<input type="text" id="node-input-filename" data-i18n="[placeholder]ftp_in.placeholder.filename">
</div>
<div class="form-row input-localFilename-row hidden">
<label for="node-input-localFilename"><i class="fa fa-file"></i> <span data-i18n="ftp_in.label.localFilename"></span></label>
<input type="text" id="node-input-localFilename" data-i18n="[placeholder]ftp_in.placeholder.localFilename">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="ftp_in.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]ftp_in.placeholder.name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('ftp in', {
category: 'storage-input',
color:"BurlyWood",
defaults: {
ftp: { type: 'ftp', required: true },
operation: { value: 'list', required: true },
filename: { value: '' },
localFilename: { value: '' },
name: { value: '' }
},
inputs: 1,
outputs: 1,
icon: "file.png",
label: function () {
var ftpNode = RED.nodes.node(this.ftp);
return this.name || 'ftp';
},
labelStyle: function () {
return this.name ? 'node_label_italic' : '';
},
oneditprepare: function () {
var filename = $(".input-filename-row");
var localFilename = $(".input-localFilename-row");
$("#node-input-operation").change(function () {
var id = $("#node-input-operation option:selected").val();
console.log(id);
if (id == 'list') {
filename.show();
localFilename.hide();
} else if (id == 'put' || id == 'get' || id == 'append') {
filename.show();
localFilename.show();
} else {
filename.show();
localFilename.hide();
}
});
}
});
</script>