You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
897 B
JavaScript
34 lines
897 B
JavaScript
import { error } from '@sveltejs/kit';
|
|
import fs from 'fs';
|
|
import stream from 'stream';
|
|
// import { canvas } from '$lib/stores/store';
|
|
import { getAllPostersFromDB, addPosterToDB } from '$lib/db/utils';
|
|
|
|
/** @type {import('./$types').PageServerLoad} */
|
|
export const load = () => {
|
|
const posters = getAllPostersFromDB();
|
|
if (posters !== undefined) {
|
|
return {
|
|
posters
|
|
}
|
|
}
|
|
throw error(404, "error");
|
|
};
|
|
|
|
/** @type {import('./$types').Actions} */
|
|
export const actions = {
|
|
default: async ({ request }) => {
|
|
console.log("Estoy aquí");
|
|
const path = crypto.randomUUID();
|
|
const data = await request.formData();
|
|
const image = data.get("image")?.toString();
|
|
const content = data.get("content");
|
|
fs.writeFileSync(`./static/${path}.png`, image, 'base64url');
|
|
// const savetoDB = addPosterToDB(image, content);
|
|
return {
|
|
success: true
|
|
}
|
|
}
|
|
|
|
}
|