W
W
Wasya UK2020-08-27 17:34:27
Node.js
Wasya UK, 2020-08-27 17:34:27

How to redirect a file on upload in Node.js?

Here is my code for uploading a file to a server. It will upload the client file in uploads.

app.use(BodyParser({
  formLimit: '10mb',
  formidable: {
    uploadDir: __dirname + '/uploads',
    keepExtensions: true
  },
  multipart: true,
  urlencoded: true
}));

Then I upload it to cloudinary, and after that I delete it from the directory. Is there a way to intercept the file and not upload it first to the server, but redirect it immediately to cloudinary or wherever I need to go via fs?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex4answ, 2020-08-27
@alex4answ

If I understand your task correctly, then you can use a stream loader that does not use temporary storage, etc., but works with streams,
for example busboy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question