import { Agentset } from "agentset";
import fs from 'fs';
const agentset = new Agentset({ apiKey: 'agentset_xxx' });
const ns = agentset.namespace('ns_xxx');
const result = await ns.uploads.upload({
file: fs.createReadStream("./example.md"),
contentType: "text/markdown",
});
console.log("Uploaded successfully: ", result.key);
// OR get the pre-signed URL manually
const file = fs.readFileSync("./example.md");
const result = await ns.uploads.create({
fileName: "example.md",
fileSize: file.length,
contentType: "text/markdown",
});
await fetch(result.url, {
method: "PUT",
body: file,
headers: {
"Content-Type": "text/markdown",
},
});
console.log("Uploaded successfully: ", result.key);