Nebula/test_upload.js
2024-08-21 00:07:18 -05:00

20 lines
598 B
JavaScript

// This is a test file to upload files to the Nebula server
import { FormData, File } from "formdata-node";
import { fileFromPath } from "formdata-node/file-from-path";
import fs from "fs";
const config = JSON.parse(fs.readFileSync("config.json", "utf8"));
const form = new FormData();
// const file = new File(["My hovercraft is full of eels"], "example.txt");
form.set("file", await fileFromPath("asgard.png"));
console.log(config.marketplace_psk);
await fetch("http://localhost:8080/api/upload-image", {
headers: {
PSK: config.marketplace_psk,
},
method: "post",
body: form,
});