ya carga archivos, ahora hay que hacer que los transforme

main
borja 1 year ago
parent 03695f71f4
commit 98c010b51c

4
.gitignore vendored

@ -10,3 +10,7 @@ node_modules
.output .output
vite.config.js.timestamp-* vite.config.js.timestamp-*
vite.config.ts.timestamp-* vite.config.ts.timestamp-*
/static/uploads/*
/static/wav/*

@ -1,3 +1,3 @@
// since there's no dynamic data here, we can prerender // since there's no dynamic data here, we can prerender
// it so that it gets served as a static asset in production // it so that it gets served as a static asset in production
export const prerender = true; // export const prerender = true;

@ -0,0 +1,16 @@
import { writeFile } from 'node:fs/promises';
/** @type {import('./$types').Actions} */
export const actions = {
default: async ({ request }) => {
const formData = await request.formData();
const uploadedFile = formData?.get('file');
console.log(uploadedFile);
const filename = `./static/uploads/${crypto.randomUUID()}-${uploadedFile?.name}`;
await writeFile(filename, Buffer.from(await uploadedFile?.arrayBuffer()));
// Bun.writeFile(filename, await uploadedFile?.arrayBuffer());
return { success: true };
}
};

@ -21,6 +21,7 @@
name="file" name="file"
accept=".mp4,.mov,.avi,.mkv,.mp3,.flac,.wav,.aac" accept=".mp4,.mov,.avi,.mkv,.mp3,.flac,.wav,.aac"
/> />
<button type="submit">Subir</button>
</form> </form>
</section> </section>
@ -38,6 +39,12 @@
margin: 1rem 0; margin: 1rem 0;
} }
button {
display: block;
margin: 2rem 0;
font-size: 1.1rem;
padding: 0.25rem 0.5rem;
}
code { code {
font-size: 1rem; font-size: 1rem;
font-family: monospace; font-family: monospace;

Loading…
Cancel
Save