test build

main
Borja Robert 2 years ago
parent b4a8e2954e
commit 9f2803d892

@ -1,33 +0,0 @@
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
}
}
}

@ -1,31 +0,0 @@
<script>
/** @type {import('./$types').PageData} */
export let data;
$: posters = data.posters;
/** @type {Blob} */ let image = new Blob();
/** @type {string} */ let template = '';
/** @type {string} */ let content = '';
</script>
<h1>Test</h1>
<ul>
{#each posters as poster}
<li>{poster.name}</li>
{/each}
</ul>
<form method="POST">
<input name="template" bind:value={template} placeholder="Plantilla" type="text" />
<input name="content" bind:value={content} placeholder="Contenido" type="text" />
<input name="image" bind:value={image} type="file" />
<button>Send</button>
</form>
<style>
input {
display: block;
margin: 1rem 0;
}
</style>
Loading…
Cancel
Save