Skip to content

Commit 306972c

Browse files
committed
added example of upload/enroll for customer
1 parent da9765e commit 306972c

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!-- This is an example of a method in which
2+
an image can be uploaded from the user"s
3+
local drive, and the image data
4+
can be extracted using FileReader and
5+
used in the payload to the enroll endpoint -->
6+
7+
<html>
8+
9+
<head>
10+
<title>Kairos Upload - Enroll Example</title>
11+
</head>
12+
<body>
13+
14+
<form method="post" enctype="multipart/form-data" id="imageUploadForm">
15+
<input type="file" id="imageUpload" name="imageUpload">
16+
<input type="submit">
17+
</form>
18+
19+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
20+
<script>
21+
$("#imageUploadForm").submit(function(e) {
22+
e.preventDefault();
23+
var input = $("#imageUpload")[0];
24+
var file = input.files[0];
25+
var reader = new FileReader();
26+
reader.readAsDataURL(file);
27+
reader.onloadend = function () {
28+
var imageData = String(reader.result);
29+
// put your keys in the header
30+
var headers = {
31+
"Content-type" : "application/json",
32+
"app_id" : "APP_ID",
33+
"app_key" : "APP_KEY"
34+
};
35+
36+
var payload = { "image" : imageData , "gallery_name" : "myGallery", "subject_id" : "mySubjectID"};
37+
38+
var url = "http://api.kairos.com/enroll";
39+
40+
// make request
41+
$.ajax(url, {
42+
headers : headers,
43+
type: "POST",
44+
data: JSON.stringify(payload),
45+
dataType: "text"
46+
}).done(function(response){
47+
console.log(JSON.parse(response));
48+
});
49+
};
50+
});
51+
</script>
52+
</body>
53+
54+
</html>

0 commit comments

Comments
 (0)