-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
140 lines (82 loc) · 3.1 KB
/
test.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
<!DOCTYPE html>
<html>
<head>
<title>AWS SDK for JavaScript - Sample Application</title>
<!--<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script>-->
</head>
<body>
<input type="file" id="file-chooser" />
<button id="upload-button">Upload to S3</button>
<div id="results"></div>
<!--<div id="fb-root"></div>-->
<script type="text/javascript">
// var appId = 'YOUR_APP_ID';
// var roleArn = 'YOUR_ROLE_ARN';
var bucketName = 'sketch.arjun.ninja';
AWS.config.region = 'ap-south-1';
// var fbUserId;
var bucket = new AWS.S3({
params: {
Bucket: bucketName
}
});
var fileChooser = document.getElementById('file-chooser');
var button = document.getElementById('upload-button');
var results = document.getElementById('results');
button.addEventListener('click', function () {
var file = fileChooser.files[0];
if (file) {
results.innerHTML = '';
//Object key will be facebook-USERID#/FILE_NAME
var objKey = 'sddsd' + '/' + file.name;
var params = {
Key: objKey,
ContentType: file.type,
Body: file,
ACL: 'public-read'
};
bucket.putObject(params, function (err, data) {
if (err) {
results.innerHTML = 'ERROR: ' + err;
} else {
listObjs();
}
});
} else {
results.innerHTML = 'Nothing to upload.';
}
}, false);
/*!
* Login to your application using Facebook.
* Uses the Facebook SDK for JavaScript available here:
* https://developers.facebook.com/docs/javascript/gettingstarted/
*/
// Load the Facebook SDK asynchronously
</script>
<!--<script type="text/javascript">
AWS.config.accessKeyId = 'AKIAIFL4ZHAOK54PZ5VQ';
AWS.config.secretAccessKey = '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';
AWS.config.region = 'ap-south-1';
// create the AWS.Request object
var s3 = new AWS.S3();
var sketch_id = 'sketch.png'
var params = {
Bucket: 'sketch.arjun.ninja',
Key: sketch_id,
ResponseContentType: 'image',
ResponseContentEncoding: 'base64'
}
s3.getObject(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data);
console.log(encodeURI(atob(data.Body))) // successful response;
});
</script>-->
<script>
</script>
<p id="status"></p>
<ul id="objects"></ul>
<!--<img src="https://s3.ap-south-1.amazonaws.com/sketch.arjun.ninja/B1Qrj9dal.png" alt="">-->
<img src="https://s3.ap-south-1.amazonaws.com/sketch.arjun.ninja/B1EGka_px.png" alt="">
</body>
</html>