> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/zh-tw/zhi-shi-ku/051-how-can-i-upload-files-from-google-drive.md).

# 我該如何從 Google Drive 上傳檔案？

## 簡介

位於您的 Google Drive 帳戶中的圖片檔案，或其他檔案資源，可以透過 [「從外部 URL」功能](/latex/zh-tw/zhi-shi-ku/081-how-to-upload-a-file-using-an-external-url.md)——前提是那些 Google Drive 檔案已啟用檔案分享。此外，您還需要建立一個合適的 URL（[直接下載連結](/latex/zh-tw/zhi-shi-ku/081-how-to-upload-a-file-using-an-external-url.md#direct-download-links-28urls29)），可用來將每個 Google Drive 檔案加入您的 Overleaf 專案：本文將說明如何操作。

從 Google Drive 上傳後，對應的 Overleaf 專案檔案隨時都可以重新整理，以便與儲存在 Google Drive 中的最新版本重新同步——[下面的影片](#video-showing-google-drive-file-upload) 示範了如何操作。

## 關於 Google 相關服務變更的注意事項與限制

檔案代管服務，例如 Google Drive，隨時都可能變更其服務；特別是修改分享連結 URL 的結構。例如，Google 在 2021 年宣布了一項 [Google Drive 安全性更新](https://support.google.com/a/answer/10685032?hl=en) ，其中加入了 `**resourcekey**` 參數到其檔案分享 URL 中。然而，由於這項更新的性質，看起來並不是所有使用者（或其所有檔案）都會立即受到這項變更影響：有些 Google Drive 使用者會看到 `**resourcekey**` 參數，其他人則可能不會。

由於這類不可預測的變更，Overleaf 不切實際提供始終保持最新且完整文件化的 Google Drive 或類似服務 URL 轉換流程——這類指引很快就可能過時，因此具有誤導性。不過，在本頁中我們提供一種方法，將包含 `**resourcekey**` 參數的 Google Drive 檔案分享 URL 轉換為可與 Overleaf 搭配使用的直接下載 URL。我們的團隊已測試此程序，而且對我們有效，但無法保證對所有人都相關或都能運作。如遇到困難，讀者首先應嘗試尋找並參考其所使用的代管服務最新提供的文件，或查閱最新文章／YouTube 影片。

## 在 Google Drive 中分享檔案

先從您想上傳到 Overleaf 專案中的 Google Drive 檔案開始：

![將 Google Drive 檔案上傳到 Overleaf](/files/47eca03ea0918df922615c585d86b575e99f6b5f)

接著，您需要 *分享* 該檔案，讓它可在 Google Drive 之外存取。以下螢幕截圖是在桌上型電腦上擷取的，示範如何在 Google Drive 內使用檔案分享與檔案連結選項：

![將 Google Drive 檔案上傳到 Overleaf](/files/d282e7cf09c2b49a1d8dd94a4003003f564e6a3c)

選擇分享檔案的選項後，會出現一個 **與人員和群組分享** 對話方塊（見下方）。在這裡，您可以選擇與特定個人／群組分享該檔案，或讓任何擁有適當 Google Drive 連結的人都可存取。

在此，我們會將連結分享設定從 **受限制** 改為 **知道連結的任何人**，改為讓任何擁有 Google Drive 連結的人都能分享，如以下在桌上型裝置（Windows 筆電）上擷取的螢幕截圖所示：

![將 Google Drive 檔案上傳到 Overleaf](/files/cc93fe5aea43752e3603ac3f0861fbff41b10082)

## 取得您已分享檔案的 Google Drive 連結

選定偏好的連結分享選項後，我們需要取得已分享檔案的 Google Drive 連結（URL）副本。有幾種方法可以做到：

* 選擇 **複製連結** ，從上方對話方塊中（如果它仍顯示在您的畫面上），或
* 在檔案上按右鍵，並選擇 **取得連結** （見下方螢幕截圖），然後從彈出方塊中選擇 **複製連結** ，或
* 選取右側顯示的連結選項（見下方螢幕截圖），然後從彈出方塊中選擇 **複製連結** 。

![將 Google Drive 檔案上傳到 Overleaf](/files/d21ac5cd148abf51a9f628c122d3fd6991235dc1)

## 為 Overleaf 建立直接下載 URL

複製 Google Drive 連結（URL）後，將它貼到您選擇的文字編輯器中——因為我們會用它來推導出 *直接下載 URL* ，以便與 Overleaf 搭配使用：這是一個 Overleaf 可用來下載 Google Drive 檔案並將其加入您專案的 URL。

將 Google Drive 連結（URL）貼到文字編輯器後，您應該會看到它具有以下結構：

```
https://drive.google.com/file/d/FILE_ID/view?usp=sharing&resourcekey=RESOURCE_KEY
```

要建構下載 URL，我們需要 Google Drive 連結中的以下組成部分：

* `FILE_ID`
* `resourcekey=RESOURCE_KEY`

這裡有一張圖片，突顯 `FILE_ID` 和 `RESOURCE_KEY` 組成部分：

![Google Drive 連結 URL 的結構](/files/23b948e8f2b5180faf8ed10133e305c980b840bb)

`FILE_ID` 和 `RESOURCE_KEY` 是很長的英數字元序列，因此在複製時請小心，以免遺漏／少複製任何字元。

在擷取出 `FILE_ID` 和 `RESOURCE_KEY`後，使用以下範本為 Overleaf 建立下載 URL：

```
https://drive.google.com/uc?export=download&id=FILE_ID&resourcekey=RESOURCE_KEY
```

這裡有一張圖片，突顯在建構完成的下載 URL 中使用 `FILE_ID` 和 `RESOURCE_KEY` 組成部分：

![Google Drive 下載 URL 的結構](/files/9e838443239409e65690348b5a8dfc9beb9db96d)

您現在已準備好將 Google Drive 檔案上傳到您的 Overleaf 專案。

## 將 Google Drive 檔案上傳至 Overleaf 專案

若要使用下載 URL，請選擇 Overleaf 的檔案上傳功能，並選擇 **「從外部 URL」**:

![將 Google Drive 檔案上傳到 Overleaf](/files/be927c5b385838fe7a435cde48bfb4ab5f9b424a)

將下載 URL 貼上，為檔案命名，然後選擇 **建立** 以將您的 Google Drive 檔案加入（上傳至）Overleaf 專案。

### Google Drive 檔案上傳示範影片

以下影片示範如何使用下載 URL 將 Google Drive 檔案加入 Overleaf 專案。

{% embed url="<https://videos.ctfassets.net/nrgyaltdicpt/2PMXTshGJI0Kg2ZtN6iXtk/18d4a3168847009a39f905c9acc45e51/Google_drive_upload.mp4>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/zh-tw/zhi-shi-ku/051-how-can-i-upload-files-from-google-drive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
