banner
阿道

阿道

阿道博客

Add GitHub as an image hosting service in MWeb

Requirements#

I have always used MWeb to write articles, and for uploading images, I have been using the built-in image publishing service, which utilizes Qiniu's image hosting, and I enabled https. Previously, the blog had low traffic and not many images, so the costs incurred from Qiniu's image hosting were minimal. However, I suddenly received a billing email from Qiniu, realizing that I had already accumulated a debt because the https traffic does not have a free quota. As the traffic increased, along with more images in subsequent articles, the costs became quite high. I thought it was really unnecessary, so I canceled https and switched to http.
After using it for a while, I found that the costs were lower, but then I thought about switching the image hosting to GitHub, which is convenient, free, and can also serve as a backup. I used the software PicGo to upload images. The next two articles had relatively few images, so there weren't any major issues. Later, one article had more than 15 images, and I found this method really cumbersome. However, MWeb itself does not support GitHub as an image host. I did a Google search and discovered the PicBed4MWeb project, which solved my problem quite well. Below, I will briefly outline the usage method.

Process#

Project Configuration#

  1. Download the project to the local directory
    git clone https://github.com/gaopeng-hz/PicBed4MWeb.git
  2. Install dependencies
    npm install
  3. Modify the config.json file in the project directory
    -w417

Refer to the following

	"repo": "gaopeng-hz/images",  // Repository name
	"token": "xxxx",  // Token, must not be public, refer to the article above for how to obtain it
	"port": 8081,  // Node server listening port, default is 8080
	"url": "/upload"  // Service upload URL, default is /upload
  1. Start the project in the project directory with node index.js, and do not close the terminal window.

MWeb Configuration#

Open the MWeb settings interface - Publishing Service - Image Hosting - Custom

-w539

Fill in according to the config

You can click the verification button at the bottom right to check if the upload service is working properly.
Successful upload will look like the image below
-w420

Normal Upload#

  1. Run in the background
    nohup node index.js &
  2. Set to start on boot
  3. Create a run.sh file in the project directory and add the following content
#!/usr/bin/env bash

# Change to your own directory
nohup node /your/path/PicBed4MWeb/index.js &
  1. Set file permissions
    sudo chmod 777 run.sh
  2. Change the opening method of the run.sh file to terminal
  3. Add to startup
    System Preferences - Users & Groups - Login Items - Add the run.sh file

Additional Content#

lsof -i :8100 Query port

kill -9 PID Close process, replace PID with the queried one

ps | grep index.js Query service PID

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.