-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_list_objects.js
40 lines (33 loc) · 965 Bytes
/
test_list_objects.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
var http = require('http');
var auth = require('./auth');
function SendRequest (method, path, headers, params) {
var options = {
hostname: 'bucketname.pek3a.qingstor.com',
port: 80,
method: method,
path: path,
headers: headers
};
var req = http.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
req.end();
req.on('error', function(e) {
console.error(e);
});
}
method = "GET";
authpath = "/bucketname";
path = "/";
headers = {};
params = {};
headers["Date"] = new Date().toUTCString();
signature = auth.GenSignature(method, authpath, headers, params);
authorization = auth.GenAuthorization(signature);
headers["Authorization"] = authorization;
console.log(headers);
SendRequest(method, path, headers, params);