PEgaz
PEgaz
Explore posts from servers
TTCTheo's Typesafe Cult
Created by PEgaz on 11/1/2023 in #questions
problem uploading files form server action
It may be a stupid question, don't kill me, I really tried to read documentation carefully ... 🙂 Since I do some image processing at first (image is passed to backend via base64 , proccessing is done with sharp in server action), my code look like this:
const uri = fileAsBase64.split(';base64,').pop();
let buffer = Buffer.from(uri as string, 'base64');
const image = await sharp(buffer)
.resize({
width: 1140,
withoutEnlargement: true,
})
.toFormat('jpg', { compression: '80' })
.toBuffer();
// .toFile(fileName);

const file = new File(
[new Blob([image], { type: 'image/jpg' })],
'sample.jpg',
{ lastModified: Date.now(), type: 'image/jpg' }
);

const response = await utapi.uploadFiles(file);
console.log({response})
const uri = fileAsBase64.split(';base64,').pop();
let buffer = Buffer.from(uri as string, 'base64');
const image = await sharp(buffer)
.resize({
width: 1140,
withoutEnlargement: true,
})
.toFormat('jpg', { compression: '80' })
.toBuffer();
// .toFile(fileName);

const file = new File(
[new Blob([image], { type: 'image/jpg' })],
'sample.jpg',
{ lastModified: Date.now(), type: 'image/jpg' }
);

const response = await utapi.uploadFiles(file);
console.log({response})
that code keeps crushing, since File is not defined in Node What's the proper way to use newly created image (saved on server file or Buffer) and invoke on server action: await utapi.uploadFiles(...); to send files to uploadThing please help regards Piotr
2 replies
RRailway
Created by PEgaz on 8/28/2023 in #✋|help
Custom domain with A record (not CNAME record)
Hi, I want to add a custom domain in one of my projects. Docs says I need to add a CNAME record in my provider. Unfortunately it's not a subdomain but main domain and my provider told me I need to use A record instead of CNAME ... so I wanted to do it, but ... record A needs IP address to be inserted, not an address. So please help me what IP address I need to provide ? project ID: a6c82679-0cee-4169-9d24-90060e2cc48a Looking forward to your help PEgaz
8 replies