fixed uploadPDF() Header problem

This commit is contained in:
David Baldwynn 2015-06-29 19:45:25 -07:00
parent c9e97cefdc
commit ebca4591fa
10 changed files with 19 additions and 22 deletions

View file

@ -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);
};
@ -112,7 +111,7 @@ exports.createSubmission = function(req, res) {
fdfData = pdfFiller.fillFdfTemplate(fdfTemplate, submission.form_fields, null);
submission.fdfData = fdfData;
//Create new file
// pdfFiller.fillForm( form.pdf.path, config.pdfUploadPath+form.title+'/'+form.title+'_'+Date.now()+'_submission.pdf', fdfData, function() {
// console.log('\n\n\n fdfData');

View file

@ -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) {

View file

@ -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);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.