title: How to add images to a database with fastify ts
body: <p>I'm a little stressed because I have no idea why this error, I'm creating a mini app where people can upload their photos, but for the backend part I don't understand very well how to do that, I'm building it with fastify- ts this is what i did</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>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&lt;File&gt;[];
  
  export interface SupportPluginOptions {}
  
  export default fp&lt;SupportPluginOptions&gt;(async (fastify, opts) =&gt; {
    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;
    }
  }</code></pre>
  </div>
  </div>
  </p>
  <p>Here I am creating the route to upload the image, when I upload an image it gives me an internal error, if someone can help me, I would really appreciate it :DDD</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { FastifyPluginAsync } from "fastify";
  import multer from "fastify-multer";
  
  const upload = multer({ dest: "upload" });
  
  const publication: FastifyPluginAsync = async (fastify, options) =&gt; {
    fastify.post(
      "/create",
      {
        preHandler: upload.single("avatar"),
      },
      async (request, reply) =&gt; {
        const { files } = request;
  
        console.log(files);
        return reply.code(200).send("SUCCESS");
      }
    );
  };
  
  export default publication;</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/rwJj5.jpg" rel="nofollow noreferrer">bug photo</a></p>
  <p>This is the git of the project I'm doing, so take a look:</p>
  <p><a href="https://i.stack.imgur.com/BSXHE.png" rel="nofollow noreferrer">bug Photo Two</a></p>
  <p>This is my example with postman</p>
  <p><a href="https://i.stack.imgur.com/LMqd2.png" rel="nofollow noreferrer">bug postman One</a></p>
  <p>///</p>
  <p><a href="https://i.stack.imgur.com/GKFeJ.png" rel="nofollow noreferrer">Bug postman Two</a></p>
  <p><a href="https://github.com/TioElvis/RedSocial" rel="nofollow noreferrer">https://github.com/TioElvis/RedSocial</a></p>