fix health-check for upload
This commit is contained in:
parent
8a44499ceb
commit
7b6bf6664f
|
@ -12,6 +12,7 @@
|
|||
"lowdb": "^1.0.0",
|
||||
"object-hash": "^2.1.1",
|
||||
"superagent": "^6.0.0",
|
||||
"tmp": "^0.2.1",
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
const fs = require("fs");
|
||||
const superagent = require("superagent");
|
||||
const tmp = require('tmp');
|
||||
const { StatusCodes } = require("http-status-codes");
|
||||
const { calculateElapsedTime, getResponseContent } = require("../utils");
|
||||
|
||||
// uploadCheck returns the result of uploading a sample file
|
||||
async function uploadCheck(done) {
|
||||
const time = process.hrtime();
|
||||
const file = tmp.fileSync();
|
||||
|
||||
fs.writeSync(file.fd, Buffer.from(new Date())); // write current date to temp file
|
||||
|
||||
superagent
|
||||
.post(`${process.env.PORTAL_URL}/skynet/skyfile`)
|
||||
.attach("file", "package.json", "package.json")
|
||||
.attach("file", file.name, file.name)
|
||||
.end((error, response) => {
|
||||
file.removeCallback();
|
||||
|
||||
const statusCode = (response && response.statusCode) || (error && error.statusCode) || null;
|
||||
|
||||
done({
|
||||
|
|
Reference in New Issue