如何使用 Dropbox PHP Core SDK 从 Dropbox 输出文件

How to output files from Dropbox with Dropbox PHP Core SDK

我想使用 Dropbox PHP Core SDK 将文件从 Dropbox 输出到我的网站上。举个例子,我将一张图片上传到 Dropbox。现在,我如何从 Dropbox 的服务器向我的网站显示该图像。请记住,我不想从 Dropbox 下载此文件然后显示该图像。是否可以使用 Dropbox PHP Core SDK 直接从 Dropbox 显示图像或其他文件?

编辑:您介意在#1

上说得更清楚吗

如何使用自定义 URL?

我可以这样做吗:header("location: $url);

这就是您使用自定义 url 的方式吗?谢谢!

使用PHP核心SDK,访问文件内容的主要方式是使用getFile method, or for images where you don't need the full resolution, the getThumbnail方法。但是,这些 return 数据直接保存在您的服务器上并返回给用户,因此不符合您所描述的需求。

听起来您更喜欢 API 而不是 return 和 link 以及可以用作 HTML 中图像来源的图像你的页面。 Dropbox API 没有提供特别适合的方法,但有一些 non-ideal 选项:

1) 您可以使用createTemporaryDirectLink 直接URL 获取图像。请注意,这些 link 会在四个小时后过期。

使用它看起来像:

list($url, $expires) = $client->createTemporaryDirectLink("/default.png");

2) 你可以使用createShareableLink to get a preview URL for the image. These links don't expire. Note that these don't link directly to the image data though, so you'd need to modify them as documented in this help article.

使用它看起来像:

$url = $client->createShareableLink("/default.png");

此外,根据 this help article

并不是说​​这两者都受带宽限制