nintendo switch

vscode automatically uploads pasted images to Douyin image hosting (new).

title: Automatically Upload Pasted Images to Dogedoge Image Hosting in VS Code (New)
date: 2021-01-18 14:37:47
tags: ['image']

About three weeks ago, I wrote an article documenting the method to automatically upload pasted images to Dogedoge image hosting in VS Code. However, during my usage in the past few weeks, I gradually discovered its limitations: it seems that due to access permission restrictions, this extension can only upload temporary photos from the clipboard and cannot upload locally copied photos. The specific issue is that the uploaded image is empty.

This prompted me to try other methods and ultimately decide to switch to vs-picgo.

Using the vs-picgo Extension

In the first article, I also mentioned that the file of vs-picgo states that it only supports eight types of image hosting services supported by PicGo-Core, and the plugin system is still a work in progress:

vs-picgo supports 8 kinds of image hosting services: weibo, qiniu, tcyun, upyun, github, aliyun, imgur and SM.MS, which are supported by PicGo-Core. And the plugin feature of PicGo-Core is working in progress.

It was because of this statement that I gave up trying it and went through the exploration process after the first article. However, after manually installing and trying it this time, I found that I may have misunderstood the developer's intention.

By carefully examining the settings of vs-picgo, I discovered a configuration item called "Config path", which states: The path to your Picgo-Core configuration. Picgo will use Picgo: Pic Bed if this is not specified. In other words, we can already override the settings of this extension by specifying the location of the Picgo Core configuration file, and thus use third-party plugins of Picgo Core. The unfinished aspect of vs-picgo may only be the graphical configuration of the plugin system...

Since that's the case, the purpose is clear. We just need to install Picgo Core and configure it accordingly, and finally specify the configuration file path in the extension.

Installing Picgo Core

Refer to the For global installation, you only need to run:

yarn global add picgo
# or
npm install picgo -g

Configuring Picgo Core

To upload to Dogedoge image hosting, we need to install the web-uploader plugin and configure it.

picgo install web-uploader
picgo config uploader

? Choose a(n) uploader # Select web-uploader
? API address # Enter your upload address
? POST parameter name # file
? Image URL JSON path (eg: data.url) # data.o_url
? Custom request headers Standard JSON (eg: {"key":"value"}) # Leave blank
? Custom Body Standard JSON (eg: {"key":"value"}) # Leave blank

picgo use uploader

? Use an uploader # Select web-uploader

After configuring, you can test if the upload is successful by running picgo upload /path/to/an/image. If the upload is successful, it means the configuration is correct.

Configuring vs-picgo

The last step is to specify the configuration file of picgo core in the vs-picgo settings. Refer to the official documentation:

The default configuration file for picgo is ~/.picgo/config.json. The ~ represents the user directory. The user directory may vary depending on the operating system.

For Linux and macOS, it is ~/.picgo/config.json.

For Windows, it is C:\Users\YourUsername.picgo\config.json.

For example, the configuration in GNU/Linux:


Using vs-picgo

Finally, let's talk about how to use it. The default shortcuts are as follows:

OSUploading an image from clipboardUploading images from explorerUploading an image from input box
Windows/UnixCtrl + Alt + UCtrl + Alt + ECtrl + Alt + O
Os XCmd + Opt + UCmd + Opt + ECmd + Opt + O
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.