Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use Baidu API to upload backup files

Shulou Source: shulou.com Published: 2022-05-31 12:06:20 10月02日 Update

This article analyzes "how to use Baidu network disk API to upload backup files". The content is detailed and easy to understand, and friends who are interested in "how to use Baidu API to upload backup files" can follow the editor's idea to read it slowly and deeply. I hope it will be helpful to everyone after reading. Next, follow the editor to learn more about "how to upload backup files using Baidu API".

1. First of all, join Baidu developer: http://developer.baidu.com/dev#/create

two。 Create an application to obtain API Key and activate PCS API permissions. Open API > API Management > API list > API Service > PCS API > enable.

3. Obtain device code and user_code from the API Key that just created the application

Curl-k-L-d "client_id=&response_type=device_code&scope=basic,netdisk"\

"https://openapi.baidu.com/oauth/2.0/device/code"

4. Open the https://openapi.baidu.com/device in the browser and enter the acquired user_code and connect it, and then get the refresh_token and access_token through device code:

Curl-k-L-d "grant_type=device_token&code=&client_id=&client_secret="\

"https://openapi.baidu.com/oauth/2.0/token"

5. At this point, you can manipulate the network disk file through access_token. The validity period of access_token is 30 days. After expiration, you can get access_token again through refresh_token.

Curl-k-L-d "grant_type=refresh_token&refresh_token=&client_id=\"

& client_secret= "

6. Obtain the quota of network disk:

Curl-k-L "https://pcs.baidu.com/rest/2.0/pcs/quota?method=\

Info&access_token= "

7. Upload files:

Curl-k-L-F "file=@haiyun.me.tar.gz"https://c.pcs.baidu.com/rest/2.0/pcs/file?method=upload&\"

Access_token=&path=/apps/pcsupload/haiyun.me.tar.gz "

8. Download the file:

Curl-k-O "https://d.pcs.baidu.com/rest/2.0/pcs/file?method=download&access_token=&\

Path=/apps/pcsupload/haiyun.me.tar.gz "

9. Delete the file:

Curl-k-L "https://pcs.baidu.com/rest/2.0/pcs/file?method=delete&access_token=\

& path=/apps/pcsupload/haiyun.me.tar.gz "

10. Copy the file:

Curl-k-L "https://c.pcs.baidu.com/rest/2.0/pcs/file?method=copy&access_token=\

& from=/apps/pcsupload/haiyun.me.tar.gz&to=/apps/pcsupload/www.haiyun.me.tar.gz "

11. List the files in the directory:

Curl-k-L "https://pcs.baidu.com/rest/2.0/pcs/file?method=list&access_token=\

& path=/apps/pcsupload/ "

About how to use Baidu network disk API to upload backup files to share here, I hope the above content can improve everyone. If you want to learn more knowledge, please pay more attention to the editor's updates. Thank you for following the website!

Tags: Files backups content knowledge follow learning applications effectiveness interests developers ideas understandability more validity friends permissions browsers directories articles websites Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker vpn macOS OPPO Reno