Total Pageviews

Monday 6 January 2020

文件上传网站的源码程序-DropIt

环境需要用到nodejs和mongodb先安装一下需要用到的工具:
apt -y update
apt -y install build-essential curl wget git gnupg nginx
安装nodejs:
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt -y install nodejs
安装mongodb:
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
apt -y update
apt -y install mongodb-org
启动mongodb/设置开机自启:
systemctl start mongod.service
systemctl enable mongod.service
拉取项目文件/安装依赖:
git clone https://github.com/ThalKod/DropIt.git /opt/dropit
cd /opt/dropit
npm i
安装pm2:
npm i -g pm2
使用pm2启动/设置开机自启:
pm2 start app.js --name dropit
pm2 startup
pm2 save
新建一个nginx反向代理段,
写入如下配置:
server {
listen  80;
server_name  mydomain.com;
client_max_body_size 10G;

location / {
proxy_pass       http://127.0.0.1:7000;
proxy_redirect             off;
proxy_set_header Host      $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
重载nginx即可
systemctl reload nginx
修改文件上传大小和个数:
nano public/js/main.js
修改这两个值即可:
const MAX_SIZE = 1000;
const MAX_FILE = 1;
修改首页的HTML可以编辑这个文件:
nano views/index.ejs
项目地址:https://github.com/ThalKod/DropIt
-------

DropIt is a File Uploader built with nodejs, Upload, get a link, and share your files with anyone easily. 

💾 Installation

# clone the repo
$ git clone https://github.com/ThalKod/DropIt.git

# install the node modules...
$ npm install

Usage

npm start

Working with your own DB ? modify config.js :

module.exports = {
    dbURL: process.env.DATABASEURL || "mongodb://localhost/dropit"
}

🐳 Docker Usage

Preparation:
  1. Rename docker-compose.yml.example to docker-compose.yml
  2. Rename .env.example to .env
  3. Fill in the missing details in .env file
Boot:
docker-compose up -d
frm https://github.com/ThalKod/DropIt