1.3.19 • Published 3 months ago
nodejs-uploder v1.3.19
nodejs file uplode online
first you will create a project and install this package:
npm i nodejs-uploder
second you will import top of this package:
const { getFile, uplodeFile } = require('nodejs-uploder')
and the process are create a express js project
const { getFile, uplodeFile } = require('nodejs-uploder')
const express = require('express');
const app = express()
app.use(express.json())
//create a image uplode api
app.post("/uploads", uplodeFile().single('image'), (req, res) => {
if (!req.file) {
return res.status(400).json({ error: "No image uploaded!" });
}
//get buffer file
const file = getFile(req.file)
console.log(file)
res.json({
message: "image get succesfully",
file // URL of the uploaded image
});
});
secand step configore cloudinary for uplode file in online database: goto your web browser and type cloudinary login and you will get
cloud_name: 'my_cloud_name',
api_key: 'my_key',
api_secret: 'my_secret'
install this package on your project
npm install cloudinary
import top of your project and configuration:
const cloudinary = require('cloudinary');
or
import cloudinary from 'cloudinary'
const { getFile, uplodeFile } = require('nodejs-uploder')
const express = require('express');
const app = express()
app.use(express.json())
```
cloudinary.v2.config({
cloud_name: 'my_cloud_name',
api_key: 'my_key',
api_secret: 'my_secret'
});
app.post("/uploads", uplodeFile().single('image'),async (req, res) => {
if (!req.file) {
return res.status(400).json({ error: "No image uploaded!" });
}
//get buffer file
const file = getFile(req.file)
console.log(file)
```
const cdb=await cloudinary.v2.uploader.upload(file.content)
console.log(cdb.public_id)
console.log(cdb.secure_url)
return res.json({
message: "image uplode succesfully",
file // URL of the uploaded image
});
});
1.3.19
3 months ago
1.2.19
3 months ago
1.2.18
3 months ago
1.2.17
3 months ago
1.2.16
3 months ago
1.2.15
3 months ago
1.2.14
3 months ago
1.2.13
3 months ago
1.2.12
3 months ago
1.1.12
3 months ago
1.1.11
3 months ago
1.1.10
3 months ago
1.0.10
3 months ago
1.0.9
3 months ago
1.0.8
3 months ago
1.0.7
3 months ago
1.0.6
3 months ago
1.0.5
3 months ago
1.0.4
3 months ago
1.0.3
3 months ago
1.0.2
3 months ago
1.0.1
3 months ago
1.0.0
3 months ago