Answer the question
In order to leave comments, you need to log in
How to save a file received via post?
The file is large, from 100MB to 1GB, so I don't want to keep it in RAM, that is, I need to save it to disk for temporary use. How to take it correctly, I have express, I looked at the documentation on the official site and did not master it, please explain to whom it is not difficult.
Answer the question
In order to leave comments, you need to log in
In general, here is a solution I got, maybe it will be useful to someone.
const express = require('express'), // Web сервер
app = express(), // Привязываем express к нашему "приложению"
multiparty = require('multiparty'); // Для сохранения файла
// Обработчик запросов
app.post('*', function(req, res) {
var form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
console.log(files.txt[0].path); // Выводим в консоль адрес файла(txt это значение поля name, то есть в данном случае name="txt")
})
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question