[英]Download the file from Google.Drive via WebClient C#
我需要在以下位置下載文件: https : //drive.google.com/u/0/uc?id=1sSR9kWifwjIP5qFWcyxGCxN0-MoEd_oo&export= download
但是在下載文件后,我只得到一個包含一行的文檔:“Google Drive-Virus scan warning”。 理論上,我應該從 url 中指定的鏈接下載文件(我是通過瀏覽器控制台獲取的),但我下載的是一行難以理解的文檔。 據我了解,我下載的是頁面標記,而不是文件本身。 如何解決這個問題?
要下載文件,請使用以下方法:
using System;
using System.Net;
public class Program
{
public static void Main(string[] args)
{
{
string url = "https://drive.google.com/u/0/uc?export=download&confirm=pKfr&id=1sSR9kWifwjIP5qFWcyxGCxN0-MoEd_oo";
string savePath = @"C:\Users\Saint\Desktop\TaskRetail\yml.xml";
WebClient client = new WebClient();
client.DownloadFile(url, savePath);
Console.ReadLine();
}
}
參考: https : //bytesbin.com/skip-google-drive-virus-scan-warning-large-files/
創建憑據:
將生成一個 API 密鑰,復制該密鑰並將其粘貼到某個地方,因為我們稍后需要它。
查找您希望在沒有任何病毒警告的情況下直接下載的 Google Drive 文件。 這里復制文件 ID 並將其粘貼到安全的地方
打開 Chrome 並輸入以下 Google API 網址。
https://www.googleapis.com/drive/v3/files/ FileID ?alt=media&key= APIKey
在 fileID 部分輸入復制的文件 ID,在 APIKey 部分輸入 API Key。
按 Enter,文件將開始下載,沒有任何警告符號。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.