> 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-cn/zhi-shi-ku/081-how-to-upload-a-file-using-an-external-url.md).

# 如何使用外部 URL 上传文件

## 引言

本文介绍如何使用 **从外部 URL** 功能。我们先简要介绍一下文件共享链接和直接下载链接。

## 文件共享链接（URL）

Google Drive、Dropbox、OneDrive 等文件托管服务使用户能够安全地共享文件：它们创建并提供文件共享链接（URL），以限制谁可以访问特定文件，并确定授予的访问模式：仅查看或可编辑。收到并随后选择或点击文件共享链接的人，可能需要先登录（验证身份）到托管服务，才能访问该文件；或者可能会进入一个“着陆页”，在该页面中可预览文件，并提供进一步的链接以手动下载文件。

## 直接下载链接（URL）

一种重要的文件链接（URL）是 [直接下载链接](https://en.wikipedia.org/wiki/Direct_download_link) 它无需进行身份验证（登录）或使用中间着陆页或其他界面即可立即下载文件：单击/选择直接下载链接即可开始下载过程。

要使用 Overleaf 的 **从外部 URL** 功能，文件托管服务（如 Google Drive、Dropbox 或 OneDrive）提供的文件共享 URL（链接）必须被 **转换** 为直接下载链接（一个不同的 URL），而转换过程会因托管网站/云服务而异。例如，以下是关于如何 [从 Dropbox 链接共享 URL 创建直接下载链接](https://help.dropbox.com/files-folders/share/force-download) （这些说明在撰写本文时是最新的）。

## Overleaf 的“从外部 URL”功能

如果您有某个文件的直接下载链接，您可以使用 Overleaf 的 **从外部 URL** 功能将其上传到您的项目中。

先选择文件上传图标，然后选择 **从外部 URL**:

![Overleaf 的“从外部 URL”功能](/files/2bb84db10cf32801f8c25623d3d8034fcfe955dc)

提供链接并为文件命名：

* **用于获取文件的 URL**：提供来自文件托管服务（如 Google Drive）的直接下载链接（URL）
* **此项目中的文件名**：为上传到项目中的文件命名，名称中不应包含空格字符

### Google Drive 示例

下面的视频演示了如何使用 Google Drive 直接下载链接上传项目文件，并展示如何在原始文件在 Google Drive 上更新或更改后刷新项目文件。

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

## 关于将链接共享 URL 转换为直接下载 URL 的说明

请读者注意以下几点：

* 文件托管服务确实会更改其链接共享 URL 的结构，例如 [Google Drive 安全更新](https://support.google.com/a/answer/10685032?hl=en)。由于这些变化，Overleaf 无法提供完整记录的 URL 转换流程，因为任何指导都可能在发布后不久就过时。读者应查找并参考其所使用的托管服务提供的最新文档，或寻找最新文章或 YouTube 视频。
* 组织/雇主可以实施安全策略/程序，阻止从用于共享组织文件和资源的 URL 创建直接下载链接。如果您在将外部文件上传到 Overleaf 时遇到困难，请联系文件共享服务的组织管理员/管理人员，询问相关情况。
* 读者也许想通过使用隐身/私密浏览器页面检查自己构造的下载链接，以确保在未登录文件共享服务的情况下它也能正常工作。


---

# 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-cn/zhi-shi-ku/081-how-to-upload-a-file-using-an-external-url.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.
