Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Baidu API to upload backup files

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report