Added S3 experiment.

This commit is contained in:
DebaucheryLibrarian 2021-02-20 01:12:44 +01:00
parent 39e2abd80a
commit f310fec869
5 changed files with 15929 additions and 220 deletions

View File

@ -19,6 +19,12 @@ module.exports = {
},
},
},
s3: {
enabled: false,
bucket: 'traxxx',
accessKey: 'ABCDEFGHIJ1234567890',
secretKey: 'abcdefghijklmnopqrstuvwxyz1234567890ABCD',
},
exclude: {
channels: [
// 21sextreme, no longer updated

16085
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -74,6 +74,7 @@
"@tensorflow/tfjs-node": "^1.5.2",
"@thependulum/bhttp": "^1.2.6",
"acorn": "^8.0.4",
"aws-sdk": "^2.847.0",
"babel-polyfill": "^6.26.0",
"bhttp": "^1.2.6",
"blake2": "^4.0.0",

40
src/utils/s3.js Normal file
View File

@ -0,0 +1,40 @@
'use strict';
const config = require('config');
const AWS = require('aws-sdk');
const fs = require('fs');
const nanoid = require('nanoid');
async function init() {
const filepath = './public/img/sfw/animals/j0iiByCxGfA.jpeg';
const endpoint = new AWS.Endpoint('s3.wasabisys.com');
const s3 = new AWS.S3({
// region: 'eu-central-1',
endpoint,
credentials: {
accessKeyId: config.s3.accessKey,
secretAccessKey: config.s3.secretKey,
},
});
try {
const data = await s3.listBuckets().promise();
const file = fs.createReadStream(filepath);
const key = `img/${nanoid()}.jpg`;
const status = await s3.upload({
Bucket: config.s3.bucket,
Body: file,
Key: key,
ContentType: 'image/jpeg',
}).promise();
console.log(data);
console.log(status);
} catch (error) {
console.log(error);
}
}
init();

View File

@ -1,14 +1,14 @@
'use strict';
const bhttp = require('bhttp');
const http = require('./http');
const sleep = 5000;
const timeout = 1000;
async function init() {
try {
const res = await bhttp.get(`https://httpstat.us/200?sleep=${sleep}`, {
responseTimeout: timeout,
const res = await http.get(`https://httpstat.us/200?sleep=${sleep}`, {
timeout,
});
console.log(res.statusCode);
@ -17,15 +17,4 @@ async function init() {
}
}
/*
/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:159
err.response = response;
^
TypeError: Cannot assign to read only property 'response' of object '[object Object]'
at addErrorData (/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:159:16)
at Timeout.timeoutHandler [as _onTimeout] (/home/pendulum/projectx/node_modules/bhttp/lib/bhttp.js:525:27)
*/
init();