Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

87
Views
Cómo agregar imágenes a una base de datos con fastify ts

Estoy un poco estresado porque no tengo idea porque este error, estoy creando una mini app donde la gente puede subir sus fotos, pero para la parte de backend no entiendo muy bien como hacer eso, estoy construyendo con fastify-ts esto es lo que hice

 import fp from "fastify-plugin"; import fastifySocket from "fastify-socket.io"; import SocketConnect from "../events/connections"; import fastifyCors from "fastify-cors"; import multer from "fastify-multer"; import { File, FilesObject } from "fastify-multer/lib/interfaces"; type FilesInRequest = FilesObject | Partial<File>[]; export interface SupportPluginOptions {} export default fp<SupportPluginOptions>(async (fastify, opts) => { fastify.decorate("someSupport", function () { return "hugs"; }); void fastify.register(fastifySocket); void fastify.register(fastifyCors); void fastify.register(SocketConnect); void fastify.register(multer.contentParser); }); declare module "fastify" { export interface FastifyInstance { someSupport(): string; } } declare module "fastify" { export interface FastifyRequest { files: FilesInRequest; } }

Aquí estoy creando la ruta para subir la imagen, cuando subo una imagen me da error interno, si alguien me puede ayudar se lo agradecería mucho :DDD

 import { FastifyPluginAsync } from "fastify"; import multer from "fastify-multer"; const upload = multer({ dest: "upload" }); const publication: FastifyPluginAsync = async (fastify, options) => { fastify.post( "/create", { preHandler: upload.single("avatar"), }, async (request, reply) => { const { files } = request; console.log(files); return reply.code(200).send("SUCCESS"); } ); }; export default publication;

foto de error

Este es el git del proyecto que estoy haciendo, así que echa un vistazo:

bicho foto dos

Este es mi ejemplo con el cartero.

error cartero uno

///

Insecto cartero dos

https://github.com/TioElvis/RedSocial

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La upload.single("avatar"), dice que está esperando un campo de avatar , pero en su llamada de cartero no establece el valor KEY en la pestaña del cuerpo.

llave de cartero

Esto resolverá.

Este es el comando curl :

 curl --location --request GET 'http://localhost:8080/publication/create' \ --form 'avatar=@"/Pictures/60iu3g.gif"'
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!