-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUsage.html
40 lines (36 loc) · 1.13 KB
/
Usage.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
// begin-snippet: Guid
function newGuid() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4)
.toString(16)
.toUpperCase()
)
}
// end-snippet
// begin-snippet: PostToBus
function PostToBus() {
var message = new Object();
message.Property1 = document.getElementById("property1").value;
message.Property2 = document.getElementById("property2").value;
var jsonString = JSON.stringify(message);
var data = new FormData();
var files = document.getElementById("files").files;
for (var i = 0; i < files.length; i++) {
data.append('files[]', files[i], files[i].name);
}
data.append("message", jsonString);
var postSettings = {
method: 'POST',
credentials: 'include',
mode: 'cors',
headers: {
'MessageType': 'SampleMessage',
'MessageNamespace': 'SampleNamespace',
'MessageId': newGuid(),
'Destination': 'Endpoint'
},
body: data
};
return fetch('SendMessage', postSettings);
}
// end-snippet