Preface#
The previous website's resource sharing was based on OneDrive storage using oneindex, but the link speed of OneDrive international version in China is really terrible. The speed of the century interconnection version is fast, but most of them can only be used for enterprise versions, which is not within the scope of consideration this time.
Since TCShare was upgraded to version 3.0, it has also added support for HeCaiyun, OneDrive, and OneDrive Century Interconnect Edition. Combined with the already supported Tianyi Cloud Drive, there are enough cloud drive options to choose from.
Since I am still a mobile user, I am using the mobile HeCaiyun, which has enough space to share some things in normal times. The most important thing is that there is no speed limit and the connection speed is very fast. It may be one of the few conscience products of China Mobile.
Setup Tutorial#
The setup method mainly includes server setup and Tencent Cloud Function (SCF) setup. Regarding server setup, it is very simple. After setting up the files, just run "composer install" to complete the installation. Below, I will mainly explain the setup method for Tencent Cloud Function (SCF).
Why choose Tencent Cloud Function? Tencent Cloud Function has a fixed amount of free quota every month, plus the first year's free monthly traffic of API Gateway. It is completely sufficient for individuals.
However, this service is not completely free. Please pay attention to the official announcements and remaining free quota when using it.
1. Download the source code to your local machine and install dependencies#
The original author stopped updating and deleted the code for some reasons, leaving only the releases. You can check my fork page for installation instructions.
After downloading the source code from Github, install PHP and Composer on your local machine. You can find the relevant installation packages for PHP and Composer here. Alternatively, you can complete the Composer dependency installation on your own server and then download the folder with the installed dependencies.
First, unzip PHP, then open composer_setup.exe and manually select the php.exe that was just extracted to install it.
After the installation is complete, use the cmd command to navigate to the folder where the source code is located and enter the command:
composer install
2. Create SCF#
Go to Tencent Cloud Function and create a new function in the left function service. You can choose the region at the top, select PHP7.2 as the runtime environment, and choose the blank function as the method.
The execution method is index.main_handler, and the submission method is to upload the local folder. Select the folder that was just created.
Click on Advanced Settings, enter the environment variables, and set them as follows. It is recommended to carefully read the documentation on Github for more information:
## Tianyi Cloud and OneDrive section
# XS is the prefix
# | -KEY is the configuration type, KEY, APP, SEC are optional
# | | - -ct is the ID of the key (similar to config.php)
# | | - | - something is the configuration name
# | | - | - | - - - - value is on the right side of the equal sign
# XS_KEY_ct_something=value
# Tianyi Cloud configuration
XS_KEY_ct=ctyun # Required, value is ctyun
XS_KEY_ct_FD= # Application folder name
XS_KEY_ct_AK= # AK
XS_KEY_ct_SK= # SK
# Onedrive configuration
XS_KEY_od=onedrive
# Century Interconnect configuration
XS_KEY_od=onedriveCN
# The value after APP can be any value, generally 123456 and so on
# ↓
XS_APP_1=/ # Mount path
XS_APP_1_NAME=TCShare # Cloud drive name
XS_APP_1_THEME=mdui # Interface theme
XS_APP_1_BASE=/ # Internal path of the cloud drive
XS_APP_1_KEY=ct # Corresponding to the ID of the Key above
## HeCaiyun section
XS_KEY_cm=caiyun
XS_KEY_cm_TOKEN='{"cyToken":"******|*|RCS|******|******","encryPhone":"******"}'
XS_APP_<id>_NAME="TCShare HeCaiyun"
XS_APP_<id>_THEME=mdui
XS_APP_<id>_BASE=/
XS_APP_<id>_KEY=cm
XS_APP_<id>=/caiyun
The left side of the equal sign is the key to be filled in, and the right side is the value to be filled in. Please note that if you are using HeCaiyun, do not fill in the TOKEN at this step, and remove the quotation marks around NAME.
After creating the function, edit it again and fill in the TOKEN. Note that the value of TOKEN should not be enclosed in single quotation marks.
Select the trigger method at the top and add a trigger method as shown in the figure below.
Open the access path to check if there are any issues. If there are no issues, you can proceed to the next step.
3. Set up API Gateway#
Go to API Gateway, select Services on the left, and there is already a service. Click on the service name to enter the settings.
Click on Custom Domain Name, enter your domain name, and upload the certificate. If you don't enable HTTPS, you don't need to do this step. Set the other settings as shown in the figure below.
After adding it, select Manage API, edit it, change the path to "/", check Enable Response Integration, select HTML as the return type, and click Complete and Publish.
4. Return to SCF and modify the environment variables#
The last step is to return to the cloud function and add an environment variable:
scf_base=/
Now you can access it by entering the domain name.
With this, the setup of TCShare using SCF is complete.
Summary#
This article uses HeCaiyun as an example, but the setup for Tianyi Cloud Drive is similar. For AK and SK, you can search for them on Github~
I personally think that TCShare has a high level of completion. I would like to express my gratitude to the original author for their efforts!
Once again, please note that SCF and API Gateway are not free products. Please pay attention to the remaining free quota when using them.
With this program, you can call audio and video resources from the cloud drive in your articles.
Reference Articles#
Tencent Cloud SCF Setup TCShare Tianyi Cloud Directory Listing
TCShare: Cloud Drive Directory Listing, Supports Tianyi Cloud