Initial Code Commit
This commit is contained in:
38
File Converter/index.js
Executable file
38
File Converter/index.js
Executable file
@@ -0,0 +1,38 @@
|
||||
import express from 'express';
|
||||
import bodyParser from 'body-parser';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import fileUpload from 'express-fileupload';
|
||||
|
||||
import { pdf } from "pdf-to-img";
|
||||
|
||||
const app = express();
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
app.use(fileUpload());
|
||||
|
||||
app.post('/convert', async(req, res) => {
|
||||
|
||||
console.log(req.files);
|
||||
|
||||
let file = req.files.pdf;
|
||||
|
||||
let images = [];
|
||||
const document = await pdf(file.data, { scale: 3 });
|
||||
|
||||
for await (const image of document) {
|
||||
images.push(image);
|
||||
}
|
||||
|
||||
res.send(images);
|
||||
});
|
||||
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World');
|
||||
});
|
||||
|
||||
app.listen(5000, () => {
|
||||
console.log('Server is running on http://localhost:3000');
|
||||
});
|
||||
21
File Converter/package.json
Executable file
21
File Converter/package.json
Executable file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "Opensource",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.20.3",
|
||||
"express": "^4.21.1",
|
||||
"express-fileupload": "^1.5.1",
|
||||
"fs": "0.0.1-security",
|
||||
"path": "^0.12.7",
|
||||
"pdf-to-img": "^4.1.1"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user