-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhttp-send-multipart-form.html
181 lines (169 loc) · 6.34 KB
/
http-send-multipart-form.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
<script type="text/javascript">
RED.nodes.registerType('http-send-multipart-form', {
category: 'function',
color: "rgb(179, 211, 249)",
defaults: {
name: {
value: ""
},
filetype: {
value: ""
},
formparts:{
value: ""
},
ret: {
value: "txt"
},
/*
filepath: {
value: ""
},
*/
url: {
value: ""
},
tls: {
type: "tls-config",
required: false
}
},
credentials: {
user: {
type: "text"
},
password: {
type: "password"
}
},
inputs: 1,
outputs: 1,
icon: "white-globe.png",
label: function() {
return this.name || "send form mpart";
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function() {
$("#node-input-useAuth").change(function() {
if ($(this).is(":checked")) {
$(".node-input-useAuth-row").show();
} else {
$(".node-input-useAuth-row").hide();
$('#node-input-user').val('');
$('#node-input-password').val('');
}
});
if (this.credentials.user || this.credentials.has_password) {
$('#node-input-useAuth').prop('checked', true);
} else {
$('#node-input-useAuth').prop('checked', false);
}
$("#node-input-useAuth").change();
function updateTLSOptions() {
if ($("#node-input-usetls").is(':checked')) {
$("#node-row-tls").show();
} else {
$("#node-row-tls").hide();
}
}
if (this.tls) {
$('#node-input-usetls').prop('checked', true);
} else {
$('#node-input-usetls').prop('checked', false);
}
updateTLSOptions();
$("#node-input-usetls").on("click", function() {
updateTLSOptions();
});
$("#node-input-ret").change(function() {
if ($("#node-input-ret").val() === "obj") {
$("#tip-json").show();
} else {
$("#tip-json").hide();
}
});
},
oneditsave: function() {
if (!$("#node-input-usetls").is(':checked')) {
$("#node-input-tls").val("_ADD_");
}
}
});
</script>
<script type="text/x-red" data-template-name="http-send-multipart-form">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name </label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
</div>
<div class="form-row">
<label for="node-input-url"><i class="fa fa-globe"></i> url </label>
<input type="text" id="node-input-url" placeholder="http://">
</div>
<!--div class="form-row">
<label for="node-input-filepath"> Filepath </label>
<input type="text" id="node-input-filepath" placeholder="/path/to/file">
</div-->
<div class="form-row">
<label for="node-input-filetype"><i class="fa fa-arrow-left"></i><span> File source type</span></label>
<select type="text" id="node-input-filetype" style="width:70%;">
<option selected value="empty"></option>
<option value="base64">Base64</option>
<option value="binary">Binary</option>
</select>
</div>
<div class="form-row">
<label for="node-input-formparts"> Form Parts </label>
<input type="text" id="node-input-formparts" placeholder="[{'chat_id': '324234234'},{'caption': 'Photo_343'}]">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-usetls" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-usetls" style="width: auto"> Enable secure (SSL/TLS) connection </label>
<div id="node-row-tls" class="hide">
<label style="width: auto; margin-left: 20px; margin-right: 10px;" for="node-input-tls"></label> Enable secure (SSL/TLS) connection <input type="text" style="width: 300px" id="node-input-tls">
</div>
</div>
<div class="form-row">
<input type="checkbox" id="node-input-useAuth" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-useAuth" style="width: 70%;"><span data-i18n="httpSendMultipart.basicauth"></span> Use basic authentication </label>
<div style="margin-left: 20px" class="node-input-useAuth-row hide">
<div class="form-row">
<label for="node-input-user"><i class="fa fa-user"></i> <span data-i18n="common.label.username"></span> Username </label>
<input type="text" id="node-input-user">
</div>
<div class="form-row">
<label for="node-input-password"><i class="fa fa-lock"></i> <span>Password</span></label>
<input type="password" id="node-input-password">
</div>
</div>
</div>
<div class="form-row">
<label for="node-input-ret"><i class="fa fa-arrow-left"></i><span> Return</span></label>
<select type="text" id="node-input-ret" style="width:70%;">
<option selected value="txt">UTF-8 string</option>
<option value="bin">Binary</option>
<option value="obj">a parsed JSON object</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="http-send-multipart-form">
<p>Provides a node for posting multipart form-data.</p>
<p>The URL must be configured in the node.</p>
<ul>
<li><code>url</code>, if set, is used as the url of the request. Must start with http: or https:</li>
<li><code>headers</code>, if set, should be an object containing field/value pairs to be added as request headers</li>
<li><code>payload</code> is sent as the body of the request</li>
<li><code>filepath</code>, if set, will load the file from the given path, relative to the location of the NodeRed project. If left blank, the node will look for the file in the root directory of the NodeRed project.</li>
</ul>
<p>When configured within the node, the URL property can contain <a href="http://mustache.github.io/mustache.5.html" target="_new">mustache-style</a> tags. These allow the url to be constructed using values of the incoming message. For example, if the url
is set to
<code>example.com/{{{topic}}}</code>, it will have the value of <code>msg.topic</code> automatically inserted. Using {{{...}}} prevents mustache from escaping characters like / & etc.</p>
<p>
The output message contains the following properties:
<ul>
<li><code>payload</code> is the body of the response</li>
<li><code>statusCode</code> is the status code of the response, or the error code if the request could not be completed</li>
<li><code>headers</code> is an object containing the response headers</li>
</ul>
</script>