-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abhishek Mittal
committed
Feb 24, 2018
0 parents
commit 381c335
Showing
4,396 changed files
with
553,832 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
var fs = require('fs'); | ||
const express=require('express'); | ||
const mammoth = require('mammoth') | ||
const start=require('./start') | ||
const path = require('path') | ||
cloudconvert = new (require('cloudconvert'))('OXBzggGenXcbU3fuZRKvxzRtLq0ZqyJkc-prJ5YPoged6TD629Fgl_tO6KwWsKJ9rTpr7CLE5lRuhzXNBlrogg'); | ||
|
||
function convert(file,new_name,format,res){ | ||
if(format=='doc'||format=='pdf'){ | ||
// create the process. see https://cloudconvert.com/apidoc#create | ||
cloudconvert.createProcess({inputformat: format, outputformat: 'docx'}, function(err, conversionProcess) { | ||
|
||
if(err) { | ||
console.error('CloudConvert Process creation failed: ' + err); | ||
} else { | ||
|
||
// start the process. see https://cloudconvert.com/apidoc#create | ||
conversionProcess.start({ | ||
outputformat: 'docx', | ||
input: 'upload' | ||
}, function (err, conversionProcess) { | ||
|
||
if (err) { | ||
console.error('CloudConvert Process start failed: ' + err); | ||
} else { | ||
|
||
// upload the input file. see https://cloudconvert.com/apidoc#upload | ||
conversionProcess.upload(fs.createReadStream(path.join(__dirname,'./uploads/'+file)), null, function (err, conversionProcess) { | ||
|
||
if (err) { | ||
console.error('CloudConvert Process upload failed: ' + err); | ||
} else { | ||
// wait until the process is finished (or completed with an error) | ||
conversionProcess.wait(function (err, conversionProcess) { | ||
if (err) { | ||
fs.unlinkSync(path.join(__dirname,'./uploads/'+file)) | ||
res.redirect('/') | ||
console.error('CloudConvert Process failed: ' + err); | ||
} else { | ||
console.log('Done: ' + conversionProcess.data.message); | ||
|
||
// download it | ||
conversionProcess.download(fs.createWriteStream("./converted/"+new_name+".docx"), null, function (err, conversionProcess) { | ||
if (err) { | ||
console.error('CloudConvert Process download failed: ' + err); | ||
} else { | ||
console.log('Downloaded to converted'); | ||
fs.unlinkSync(path.join(__dirname,'./uploads/'+file)) | ||
start.check(new_name,res); | ||
// fs.unlinkSync('./converted/' +new_name+'.docx') | ||
// mammoth.convertToHtml({path: __dirname + "/converted1.docx"}) | ||
// .then(function(result){ | ||
// console.log(result.value); | ||
// }) //end of mammoth | ||
// .done(); | ||
} | ||
}); | ||
} | ||
|
||
}); | ||
} | ||
}); | ||
|
||
|
||
} | ||
}); | ||
} | ||
|
||
}); | ||
} | ||
} | ||
module.exports={convert} |
Oops, something went wrong.