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

422
Views
I don't know why it gives me this error with fastify-ts, multer and cloudinary

I'm new to this, and I don't understand some things, but according to me this error is very strange, I'm using fastify-ts, multer and cloudinary, I want to tell result that the file path is the file to upload, but it doesn't tell me let

This is the code where I do the request:

fastify.post<{
Body: CreatePublicationBody;
Params: CreatePublicationParams;
}>(
"/create/:userId",
{
preHandler: upload,
},
async (request, reply) => {
const { description } = request?.body;
const { userId } = request.params;
const { path } = request.file;

  const result = await v2.uploader.upload(path);

  console.log(result);

  const payload = {
    userId: userId,
    description: description,
    image: result.secure_url,
  };

  await fastify.store.Publication.create(payload, (err, data) => {
    if (err || !data) {
      throw new Error("Error to create Publication");
    } else {
      return reply.status(200).send(data);
    }
  });

  return "ok";
}
);

This is the error it gives me

enter image description here

And this is how I record it:

import fp from "fastify-plugin";
import multer from "fastify-multer";
import { File, FilesObject } from "fastify-multer/lib/interfaces";
import { v2 } from "cloudinary";

export default fp(async (fastify, opts) => {
fastify.decorate("someSupport", function () {
return "hugs";
});

void fastify.register(multer.contentParser);

v2.config({
cloud_name: process.env.CLOUD_NAME,
api_key: process.env.API_KEY,
api_secret: process.env.API_SECRET,
});

});

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

0

I believe your upload method expects a callback function as the second parameter, like this:

cloudinary.uploader.upload(path, function(error, result) {console.log(result, error)});

For reference: https://cloudinary.com/documentation/node_integration#quick_example_file_upload

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!