> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/zhi-shi-ku/081-how-to-upload-a-file-using-an-external-url.md).

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

## 引言

本文说明如何使用 **从外部 URL** 功能将外部托管的文件上传到您的 Overleaf 项目中。我们先简要介绍一下文件共享链接和直接下载链接。

## 文件共享链接（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://ayakaleaf-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.
