如何使用Dropbox的PHP核心SDK从Dropbox的输出文件 [英] How to output files from Dropbox with Dropbox PHP Core SDK

查看:357
本文介绍了如何使用Dropbox的PHP核心SDK从Dropbox的输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要的输出从Dropbox的文件到我的网站Dropbox的PHP核心SDK 即可。举个例子,我上传到Dropbox的图像。现在,我怎么显示的图像到我的网站从Dropbox的的服务器。请记住,我并不想从Dropbox的下载这个文件,然后显示图像。是否有可能显示图像或使用Dropbox的PHP核心SDK从另一个Dropbox的直接文件?

I want to output a file from Dropbox onto my website with Dropbox PHP Core SDK. To give an example, I upload an image to Dropbox. Now, how do I display that image to my website from Dropbox's servers. Keep in mind, I don't want to download this file from Dropbox and then display that image. Is it possible to display an image or another file directly from Dropbox using Dropbox PHP Core SDK?

编辑:你会介意在#更清晰1

我如何使用自定义网址?

How do I use the custom URL?

我可以这样做:标题(位置:$网址);

这是你如何使用自定义网址?谢谢!

Is this how you use the custom url? Thanks!

推荐答案

使用PHP核心SDK,使用的 的GetFile 方法,或者,你不需要全分辨率,在<一个图像href=\"https://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/class-Dropbox.Client.html#_getThumbnail\"相对=nofollow> getThumbnail 方法。然而,这些直接返回数据,例如,以节省您的服务器上,服务返回给用户,让不适合描述你的需求。

Using the PHP Core SDK, the main way of accessing file content is using the getFile method, or for images where you don't need the full resolution, the getThumbnail method. However, these return the data directly, e.g., to save on your server and serve back to the user, so that doesn't suit your needs as described.

这听起来像你preFER API来一个链接返回到可以为源在你的页面的HTML图像使用的图像。 Dropbox的API不提供特别适合于一个方法,但也有一些不理想的选项:

It sounds like you'd prefer the API to return a link to the image that you can use as the source for the images in the HTML of your page. The Dropbox API doesn't offer a method particularly well suited for that, but there are some non-ideal options:

1)你可以使用<一个href=\"https://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/class-Dropbox.Client.html#_createTemporaryDirectLink\"相对=nofollow> createTemporaryDirectLink 得到一个直接的URL的形象。请注意,这些链接四个小时以后到期,但。

1) You can use createTemporaryDirectLink to get a direct URL to the image. Note that these links expire after four hours though.

使用它看起来像:

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

2)你可以使用<一个href=\"https://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/class-Dropbox.Client.html#_createShareableLink\"相对=nofollow> createShareableLink 获得的图像preVIEW URL。这些链接不​​会过期。请注意,这些不直接链接到的图像数据,因此你就需要修改它们在记录此帮助文章

使用它看起来像:

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

另外,不是说这两个都受到带宽的限制,每此帮助文章

这篇关于如何使用Dropbox的PHP核心SDK从Dropbox的输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆