fixed uploadPDF() Header problem
This commit is contained in:
parent
c9e97cefdc
commit
ebca4591fa
|
@ -38,7 +38,7 @@ exports.create = function(req, res) {
|
|||
/**
|
||||
* Upload PDF
|
||||
*/
|
||||
exports.uploadPDF = function(req, res, next) {
|
||||
exports.uploadPDF = function(req, res) {
|
||||
var parser = new PDFParser(),
|
||||
pdfFile = req.files.file;
|
||||
|
||||
|
@ -50,34 +50,33 @@ exports.uploadPDF = function(req, res, next) {
|
|||
if (req.files) {
|
||||
|
||||
if (pdfFile.size === 0) {
|
||||
return next(new Error('Hey, first would you select a file?'));
|
||||
return res.status(400).send({
|
||||
message: 'Hey, first would you select a file?'
|
||||
});
|
||||
}
|
||||
fs.exists(pdfFile.path, function(exists) {
|
||||
if(exists) {
|
||||
console.log('UPLOADING FILE \N\N');
|
||||
res.end('Got your file!');
|
||||
next();
|
||||
// return res.status(200);
|
||||
// console.log('UPLOADING FILE \N\N');
|
||||
return res.status(200).send({
|
||||
message: 'Got your file!'
|
||||
});
|
||||
} else {
|
||||
res.end('DID NOT get your file!');
|
||||
next();
|
||||
// return res.status(400);
|
||||
return res.status(400).send({
|
||||
message: 'Did NOT get your file!'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
next(new Error('FILE NOT UPLOADED'));
|
||||
|
||||
// return res.status(400);
|
||||
// res.json(pdfFile);
|
||||
return res.status(400).send({
|
||||
message: 'FILE NOT UPLOADED'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the current form
|
||||
*/
|
||||
exports.read = function(req, res) {
|
||||
// console.log(req.form);
|
||||
console.log(req.form.form_fields[7]);
|
||||
res.json(req.form);
|
||||
};
|
||||
|
||||
|
|
|
@ -111,7 +111,6 @@ FormSchema.pre('save', function (next) {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
//Autogenerate FORM from PDF if 'isGenerated' flag is 'true'
|
||||
FormSchema.pre('save', function (next) {
|
||||
var field;
|
||||
|
@ -164,7 +163,6 @@ FormSchema.pre('save', function (next) {
|
|||
|
||||
//Throw error if we encounter form with invalid type
|
||||
next();
|
||||
|
||||
});
|
||||
|
||||
FormSchema.methods.convertToFDF = function (cb) {
|
||||
|
|
|
@ -97,14 +97,14 @@ FormSubmissionSchema.pre('save', function (next) {
|
|||
|
||||
|
||||
pdfFiller.fillForm(_form.pdf.path, dest_path, this.fdfData, function(err){
|
||||
console.log("fdfData: \n");
|
||||
console.log('fdfData: \n');
|
||||
console.log(that.fdfData);
|
||||
|
||||
// console.log("_form.pdf.path: "+_form.pdf.path);
|
||||
// console.log("dest_path: "+dest_path);
|
||||
// console.log('_form.pdf.path: '+_form.pdf.path);
|
||||
// console.log('dest_path: '+dest_path);
|
||||
|
||||
if(err) {
|
||||
console.log("\n err.message: "+err.message);
|
||||
console.log('\n err.message: '+err.message);
|
||||
next( new Error(err.message) );
|
||||
}
|
||||
console.log('Field data from Form: '+_form.title.trim()+' outputed to new PDF: '+dest_path);
|
||||
|
|
BIN
uploads/pdfs/snthsnthsnth_submission_1435630540895.pdf
Normal file
BIN
uploads/pdfs/snthsnthsnth_submission_1435630540895.pdf
Normal file
Binary file not shown.
BIN
uploads/pdfs/snthsnthsnth_submission_1435631451599.pdf
Normal file
BIN
uploads/pdfs/snthsnthsnth_submission_1435631451599.pdf
Normal file
Binary file not shown.
BIN
uploads/pdfs/snthsnthsnth_submission_1435631701333.pdf
Normal file
BIN
uploads/pdfs/snthsnthsnth_submission_1435631701333.pdf
Normal file
Binary file not shown.
BIN
uploads/pdfs/snthsnthsnth_submission_1435632021223.pdf
Normal file
BIN
uploads/pdfs/snthsnthsnth_submission_1435632021223.pdf
Normal file
Binary file not shown.
BIN
uploads/pdfs/snthsnthsnth_submission_1435632187529.pdf
Normal file
BIN
uploads/pdfs/snthsnthsnth_submission_1435632187529.pdf
Normal file
Binary file not shown.
BIN
uploads/tmp/1435631554812.pdf
Normal file
BIN
uploads/tmp/1435631554812.pdf
Normal file
Binary file not shown.
BIN
uploads/tmp/1435632257136.pdf
Normal file
BIN
uploads/tmp/1435632257136.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue