我想将文件上传到API,为此,我正在使用multer和express。以下是我的代码:-
const app = express();
app.use(function(req, res, next) {
res.header("Authorization: Basic X3llMVI3Mk9PdzFHOXBqcW1GaVp2NHJINjRxNDZVMlU6czIvL2JmOGM0ZDVhMjliYWUzNzgxZWQwZGY4ZDVmYmYzZjY4ZDE5OGM4YWZmY2EyZjM0YWYyNjNiNSzYgNDE1ZTE1Njc=");
next();
});
var storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '@/var/www/html/git/testplaterate/PlateRate/')
},
filename: function (req, file, cb) {
cb(null, 'achupload.csv') //Retains the original file name
}
})
var upload = multer({ storage: storage })
console.log("upload=====",upload);
app.post("https://secure.usaepay.com/api/v2/bulk_transactions", upload.single('@/var/www/html/git/testplaterate/PlateRate/achupload.csv'), function(req, res) {
console.log("files = ===");
});
但是当我管理“文件”时,没有显示控制台。仅显示上传控制台。