-
Notifications
You must be signed in to change notification settings - Fork 2
/
ftp-download.html
186 lines (172 loc) · 8.15 KB
/
ftp-download.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
<!--
Copyright 2017 Tyler Eastman.
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-download-server">
<div class="form-row">
<label for="node-config-input-host"><i class="fa fa-server"></i> <span data-i18n="server.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="server.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="server.username"></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="server.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="server.connection_timeout"></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="server.pasv_timeout"></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="server.keepalive"></span></label>
<input type="text" id="node-config-input-keepalive" placeholder="10000">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> <span data-i18n="server.name"></span></label>
<input type="text" id="node-config-input-name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('ftp-download-server', {
category: 'config',
defaults: {
host: { value: '', required:true },
port: { value: 21, required:true, validate:RED.validators.number()},
user: { value: '' },
connTimeout: { value: 10000, required:true, validate:RED.validators.number()},
pasvTimeout: { value: 10000, required:true, validate:RED.validators.number()},
keepalive: { value: 10000, required:true, validate:RED.validators.number()},
name: {value: ''}
},
credentials: {
password: { type: 'password', required: true }
},
label: function() {
return this.name || (this.host + ":" + this.port);
}
});
</script>
<script type="text/x-red" data-template-name="ftp-download">
<div class="form-row">
<label for="node-input-server"><i class="fa fa-server"></i> <span data-i18n="download.server"></span></label>
<input type="text" id="node-input-server">
</div>
<div class="form-row">
<label for="node-input-files"><i class="fa fa-file"></i> <span data-i18n="download.files"></span></label>
<input type="text" id="node-input-files" placeholder="Filenames">
</div>
<div class="form-row">
<label for="node-input-directory"><i class="fa fa-folder"></i> <span data-i18n="download.directory"></span></label>
<input type="text" id="node-input-directory" placeholder="Local Folder">
</div>
<div class="form-row">
<label for="node-input-output"><i class="fa fa-sign-out"></i> <span data-i18n="download.output"></span></label>
<input type="text" id="node-input-output" placeholder="payload">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="download.name"></span></label>
<input type="text" id="node-input-name">
</div>
</script>
<script type="text/x-red" data-help-name="ftp-download">
<p>Downloads files from an FTP server to a local directory.</p>
<h3>Details</h3>
<p>This node will connect to the specified 'server' and attempt to download all file paths defined in the 'File(s)'
field and place them in the 'directory' directory. This occurs within a single connection, so if any of the files
fail, an error will be thrown and the rest will fail.</p>
<h3>Inputs</h3>
<p>The 'File(s)' input may be defined from the following sources.</p>
<dl class="message-properties">
<dt>msg.</dt>
<dd>A variable on the msg, must be an Array of path Strings or source Objects.</dd>
<dt>flow.</dt>
<dd>A variable in the flow context, must be an Array of path Strings or source Objects.</dd>
<dt>global.</dt>
<dd>A variable in the global context, must be an Array of path Strings or source Objects.</dd>
<dt>json</dt>
<dd>An Array of path strings or source Objects.</dd>
<dt>string</dt>
<dd>A single path string.</dd>
</dl>
<code>
global.test = ["/path/to/ftp.file", "/path/to/another/ftp.file"];
</code>
or
<code>
global.test = [
{
"src": "/path/to/ftp.file",
"dest": "/path/to/local.file"
}, {
"src": "/path/to/another/ftp.file",
"dest": "/path/to/another/local.file"
}
];
</code>
<p>The 'directory' input may be defined from the following sources.</p>
<dl class="message-properties">
<dt>msg.</dt>
<dd>A variable on the msg, must be a local path.</dd>
<dt>flow.</dt>
<dd>A variable in the flow context, must be a local path.</dd>
<dt>global.</dt>
<dd>A variable in the global context, must be a local path.</dd>
<dt>string</dt>
<dd>A single local path string.</dd>
</dl>
<p>Reads a list of file paths from the File(s) input. The files defined in the files field will be downloaded into the directory field, if the files field is an array of
objects with dest fields set. The final destination will be `directory + "/" + file.dest`</p>
<h3>Outputs</h3>
<p>The node outputs an Array of local path Strings which indicate where the files were downloaded to.</p>
<p>The "Output" variable may be set to define where the output Array of file names will be put. By default <code>msg.payload</code> is used.</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/teastman/node-red-contrib-ftp-download">GitHub</a> - node-red-contrib-ftp-download repository</li>
</ul>
</script>
<script type="text/javascript">
RED.nodes.registerType('ftp-download', {
category: 'storage-input',
defaults: {
server: {type: 'ftp-download-server', required: true},
files: {value: '', required: true},
directory: {value: ''},
name: {value: ''},
output: {value: 'payload', required: true},
filesType: { value:"str" },
directoryType: { value:"str" }
},
inputs: 1,
outputs: 1,
color: "BurlyWood",
icon: "file.png",
label: function () {
return this.name || 'FTP Download';
},
oneditprepare: function () {
$("#node-input-files").typedInput({default:this.filesType||'str',types: ["str", "json", "msg", "flow", "global"]});
$("#node-input-directory").typedInput({default:this.directoryType||'str',types: ["str", "msg", "flow", "global"]});
$("#node-input-output").typedInput({types: ["msg"]});
},
oneditsave: function() {
this.filesType = $("#node-input-files").typedInput('type');
this.directoryType = $("#node-input-directory").typedInput('type');
}
});
</script>