Imoxto
Imoxto
TTCTheo's Typesafe Cult
Created by Imoxto on 3/18/2024 in #questions
Upload file from nodejs local path
Im just trying to write a simple node js script that will upload a local file to uploadthing but get the following error: UploadThingError: Invalid request input Here is the node JS script:
async function uploadFile() {
const utapi = new UTApi();

const buffer = fs.readFileSync(`./dist/${filename}`);
const blob = new Blob([buffer]);

try {
await utapi.deleteFiles(pkgJson.name, { keyType: 'customId' });
} catch (error) {
console.log('error deleting files');
console.error(error);
}

try {
const response = await utapi.uploadFiles({
...blob,
name: filename,
customId: pkgJson.name,
});
console.log(JSON.stringify(response, null, 2));
} catch (error) {
console.log('error uploading files');
console.error(error);
}
}
async function uploadFile() {
const utapi = new UTApi();

const buffer = fs.readFileSync(`./dist/${filename}`);
const blob = new Blob([buffer]);

try {
await utapi.deleteFiles(pkgJson.name, { keyType: 'customId' });
} catch (error) {
console.log('error deleting files');
console.error(error);
}

try {
const response = await utapi.uploadFiles({
...blob,
name: filename,
customId: pkgJson.name,
});
console.log(JSON.stringify(response, null, 2));
} catch (error) {
console.log('error uploading files');
console.error(error);
}
}
Plz help guide me through this thanks 📿
4 replies
TTCTheo's Typesafe Cult
Created by Imoxto on 4/14/2023 in #questions
websocket (ws package) client connection keeps restarting on ct3a project.
2 replies