Commit 0706f944 authored by Yoann HOUPERT's avatar Yoann HOUPERT

use request body instead of file

parent c335b71e
Pipeline #6910 failed with stage
in 24 seconds
......@@ -21,7 +21,6 @@ const https = require('https');
const fs = require('fs');
const app = require('express')();
const fileUpload = require('express-fileupload');
const bodyParser = require('body-parser');
const config = require('./config.json');
......@@ -29,8 +28,7 @@ const routes = require('./lib/webserver/routes');
console.log('starting routes linstt-controller...');
app.use(bodyParser.raw({type: 'audio/wav', limit: '200mb'}));
app.use(fileUpload());
app.use(bodyParser.raw({type: 'audio/wave', limit: '200mb'}));
app.use('/', routes.routesFactory(config.orchestrator));
app.listen(config.api, () => {
......
......@@ -29,7 +29,7 @@ module.exports = config => {
url,
formData: {
wavFile: {
value: wavFile.data,
value: wavFile,
options: {
filename: 'wavFile',
contentType: 'audio/x-wav'
......
......@@ -26,14 +26,11 @@ const routesFactory = config => {
const checker = require('../util/checker');
routes.post('/api/transcript', (req, res) => {
if (!req.files) {
if(!req.body){
return res.status(400).send('No files were uploaded.');
}
if (!checker.isFileValid(req.files.wav)) {
return res.status(400).send('File is not valid.');
}
enhancer.enhancement(req.files.wav, (err, httpResponse, body) => {
enhancer.enhancement(req.body, (err, httpResponse, body) => {
if (err) {
return res.status(500).send('Error while enhancing audio.' + err);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment