static/uploads -> uploads
This commit is contained in:
parent
851309f58f
commit
3b428215e3
@ -848,7 +848,7 @@ export async function getApplications(postingId: number): Promise<Application[]>
|
||||
phone: application.phone,
|
||||
fullName: application.fullName,
|
||||
resume: fs.existsSync(
|
||||
path.join(process.cwd(), 'static', 'uploads', 'resumes', `${application.userId}.pdf`)
|
||||
path.join(process.cwd(), 'uploads', 'resumes', `${application.userId}.pdf`)
|
||||
)
|
||||
};
|
||||
delete application.userId;
|
||||
|
||||
@ -10,7 +10,7 @@ export async function saveAvatar(user: User): Promise<void> {
|
||||
const url = `https://ui-avatars.com/api/?background=random&format=svg&name=${user.fullName ? encodeURIComponent(user.fullName) : encodeURIComponent(user.username)}`;
|
||||
const response = await fetch(url, { headers: { accept: 'image/svg+xml' } });
|
||||
const avatar = await response.text();
|
||||
const filePath = path.join('static', 'uploads', 'avatars', `${user.id}.svg`);
|
||||
const filePath = path.join('uploads', 'avatars', `${user.id}.svg`);
|
||||
fs.writeFileSync(filePath, avatar);
|
||||
}
|
||||
|
||||
@ -18,12 +18,12 @@ export async function saveLogo(company: Company): Promise<void> {
|
||||
// const url = `https://ui-avatars.com/api/?background=random&format=svg&name=${encodeURIComponent(company.name!)}`;
|
||||
// const response = await fetch(url, { headers: { accept: 'image/svg+xml' } });
|
||||
// const avatar = await response.text();
|
||||
// const filePath = path.join('static', 'uploads', 'logos', `${company.id}.svg`);
|
||||
// const filePath = path.join('uploads', 'logos', `${company.id}.svg`);
|
||||
const url = `https://img.logo.dev/${new URL(company.website!).hostname}`;
|
||||
console.log(url);
|
||||
const response = await fetch(url, { headers: { accept: 'image/jpeg' } });
|
||||
const avatar = await response.buffer();
|
||||
const filePath = path.join('static', 'uploads', 'logos', `${company.id}.jpg`);
|
||||
const filePath = path.join('uploads', 'logos', `${company.id}.jpg`);
|
||||
fs.writeFileSync(filePath, avatar);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ export async function deleteLogo(company: Company): Promise<void> {
|
||||
// const url = `https://ui-avatars.com/api/?background=random&format=svg&name=${encodeURIComponent(company.name!)}`;
|
||||
// const response = await fetch(url, { headers: { accept: 'image/svg+xml' } });
|
||||
// const avatar = await response.text();
|
||||
const filePath = path.join('static', 'uploads', 'logos', `${company.id}.jpg`);
|
||||
const filePath = path.join('uploads', 'logos', `${company.id}.jpg`);
|
||||
fs.rmSync(filePath);
|
||||
}
|
||||
|
||||
|
||||
@ -9,9 +9,7 @@ import { writeFileSync } from 'fs';
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
const id = getUserId(cookies);
|
||||
const userData = await getUserWithCompanyAndApplications(id);
|
||||
const resumeExists = fs.existsSync(
|
||||
path.join(process.cwd(), 'static', 'uploads', 'resumes', `${id}.pdf`)
|
||||
);
|
||||
const resumeExists = fs.existsSync(path.join(process.cwd(), 'uploads', 'resumes', `${id}.pdf`));
|
||||
|
||||
return {
|
||||
...userData,
|
||||
@ -36,7 +34,7 @@ export const actions: Actions = {
|
||||
fail(400, { message: 'invalid' });
|
||||
}
|
||||
writeFileSync(
|
||||
`static/uploads/resumes/${getUserId(cookies)}.pdf`,
|
||||
`uploads/resumes/${getUserId(cookies)}.pdf`,
|
||||
Buffer.from(await file.arrayBuffer())
|
||||
);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user