fileuploadservice
v1.0.4
Published
it is usefull for the upload files
Downloads
5
Maintainers
Readme
file-upload-service
Install
npm install fileuploadservice;
index.js
const express = require("express");
const {fileUploadService , singleUpload , uploadToCloudinary} = require('fileuploadservice');
const app = express();
app.post("/",async(req,res)=>{
const rootpath = your_file_storage_path
fileUploadService(req, rootpath, (err) => {
if (err) {
return res.status(500).send(err.message);
}
res.send('Files uploaded successfully.');
});
res.status(200) ;
})
app.post("/singlefile",async(req,res)=>{
const rootpath = your_file_storage_path
singleUpload(req, rootpath, (err) => {
if (err) {
return res.status(500).send(err.message);
}
res.send('File uploaded successfully.');
});
res.status(200) ;
})
app.post("/cloudinary",async(req,res)=>{
await uploadToCloudinary(req, cred, (err, images) => {
if (err) {
return res.status(500).send(err.message);
}
res.status(200).send(images);
});
})
app.listen(PORT,()=>{
console.log("server run successfully")
})