1.0.10 • Published 5 years ago

freeupload v1.0.10

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

Free File Uploader 🌱

License

Free upload is a package for uploading & keeping image to google-cloud/storage via firebase without charge or adding credit card.

Note: Need some firebase credentials and Google cloud credential.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm i freeupload

Usages

const express = require("express");
const bodyParser = require("body-parser");
const freeUpload = require("freeupload");
const Multer = require('multer');

const keyFilename = 'serviceaccount.json'; //keep the file (downloaded from google cloud service account) in your ptojects root directory and replace the serviceaccount.json with the filename
const bucketName = 'projectId.appspot.com'; // replace projectId with your firebase project Id
const projectId = "projectId"; // replace projectId with your firebase project Id

const app = express();

const multer = Multer ({
  storage: Multer.memoryStorage (),
  limits: {
    fileSize: 5 * 1024 * 1024, // no larger than 5mb, you can change as needed.
  },
});

//Body Parser Middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());


app.post (
  '/upload',
  multer.single ('file'),
  async (req, res) => {
    let file = req.file;
        if (file) {
          try{
            let url = await freeUpload.upload (file, keyFilename , bucketName, projectId);
            res.json(url);
          }
          catch(err){

          }
        }
  }
);

const port = process.env.PORT || 8085;
app.listen(port, () => 
  console.log(`Server Running On Port ${port}`)
);

Firebase credentailas manage

##Steps Go to firebase console

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

Google cloud credentailas manage

##Steps

1

10

2

11

3

12

4

13

5

14

6

15

7

16

8

17

9

18

10

19

11

20

12

21

13

22

14

23

1.0.10

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago