forked from binvant/MakeMyCareer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
108 lines (104 loc) · 3.07 KB
/
script.js
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
//const fs = require('fs');
//const AWS = require('aws-sdk');
let temp;
function convertToBase64(selectedFile) {
//Read File
//Check File is not Empty
console.log(selectedFile)
if (selectedFile) {
console.log("Inside if")
// Select the very first file from list
var fileToLoad = selectedFile;
// FileReader function for read the file.
var fileReader = new FileReader();
var base64;
// Onload of file read the file content
fileReader.onload = function(fileLoadedEvent) {
temp = fileLoadedEvent.target.result;
// Print data in console
console.log(base64);
};
// Convert data to base64
console.log("Filetoload")
console.log(fileToLoad)
let toReturn = fileReader.readAsDataURL(fileToLoad);
console.log("done")
console.log(toReturn);
return temp;
}
}
function render(){
window.location.replace("http://makemycareer.s3-website-us-east-1.amazonaws.com/recruitersignup.html")
}
function signup() {
let name = $('#name').val();
let email = $('#mail').val();
let password = $('#password').val();
$.ajax({
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'OPTIONS, POST',
'Content-Type': 'application/json'
},
contentType: "application/json",
method: "POST",
url: "https://jwjkqbwke5.execute-api.us-east-1.amazonaws.com/dev/createprofile",
data: JSON.stringify({
"name": name,
"email": email,
"password": password
})
}).done(function() {
$(this).addClass( "done" );
});
var fd = new FormData();
var File = document.getElementById("myFile").files[0];
let promise = new Promise((resolve, reject) => {
//resolve(convertToBase64(File));
//File = convertToBase64(File);
convertToBase64(File);
//console.log("Just after function return");
//console.log(temp);
let that = this;
setTimeout(() => {
//temp = convertToBase64(File);
console.log("The file sent in resolve");
console.log(temp);
resolve(temp);
}, 3000);
/*if (File){
resolve(File);
}else {
reject(File);
}*/
});
promise.then(
function() {
console.log("Inside resolve");
resolveUpload(File);
},
function(Fie){
rejectUpload(File);
}
);
}
function resolveUpload(File){
console.log("Filee")
console.log(temp)
$.ajax({headers:{
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': 'OPTIONS, POST',
},
url: "https://jwjkqbwke5.execute-api.us-east-1.amazonaws.com/dev/uploadresume",
method: "POST",
data: temp,
isBase64Encoded: false
}).done(function (response) {
console.log(response);
});
}
function rejectUpload(inp){
console.log(inp)
}