如何上传到Dropbox公用文件夹并获取公用URL? [英] How to upload to Dropbox Public folder and get public URL?

查看:117
本文介绍了如何上传到Dropbox公用文件夹并获取公用URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一种情况,我需要将文件上传到我的Dropbox公用文件夹,并且一旦上传,我还需要存储上传文件的公共URL?我正在使用python,对此的任何帮助都会很棒。

I have a situation, where I need to upload a file to my Dropbox Public Folder, and also once uploaded I need to store the uploaded file's public url ? I am using python, and any help on this would be great.

谢谢。

推荐答案

使用它在您的程序中设置Python SDK

Use this to set up a Python SDK in your program

https://www.dropbox.com/developers/start/setup#python

您所有的文件信息:

folder_metadata = client.metadata('/')

我相信您在谈论这些短链接,正如您所知,公用文件夹中的每个小链接仅由特殊请求生成,并且具有

I beleive you are talking about these short links, just so you know, every small link from the public folder is generated only by special request and has an expiration date.

如果想要永久链接,请跳至步骤2。

If you want a permanent link skip to step 2.

此信息来自: https:// www .dropbox.com / developers / reference / api

/shares

描述

创建并返回指向文件或文件夹的共享链接。

Creates and returns a shareable link to files or folders.

注意:链接由/ shares API调用创建的内容在30天后失效。

Note: Links created by the /shares API call expire after thirty days.

URL结构

https://api.dropbox.com/1/shares/<root>/<路径>

root 相对于其指定路径的根。有效值为沙箱和保管箱。

root The root relative to which path is specified. Valid values are sandbox and dropbox.

path 您要共享链接的文件或文件夹的路径。

path The path to the file or folder you want a shareable link to.

版本

0,1

方法

POST

参数

区域设置为用户错误消息和其他语言指定语言设置

locale Use to specify language settings for user error messages and other language

特定文本。有关支持的语言环境的更多信息,请参见上面的注释。

specific text. See the notes above for more information about supported locales.

返回

指向文件或文件夹的可共享链接。该链接可以公共使用,并指向文件的预览页。还以Dropbox的常规日期格式返回链接的到期日期。

A shareable link to the file or folder. The link can be used publicly and directs to a preview page of the file. Also returns the link's expiration date in Dropbox's usual date format.

文件的示例JSON返回值

Sample JSON return value for a file

{
    "url": "http://db.tt/APqhX1",
    "expires": "Wed, 17 Aug 2011 02:34:33 +0000"
}

如果执行了步骤1,请不要执行步骤2。

If you did step 1 don't do step 2.

/files (GET)

描述

下载文件。请注意,此调用转到api内容服务器。

Downloads a file. Note that this call goes to the api-content server.

URL结构

https://api-content.dropbox.com/1/files/<root>/<path>

root相对于指定路径的根。有效值为沙箱和保管箱。
path要检索的文件的路径。

root The root relative to which path is specified. Valid values are sandbox and dropbox. path The path to the file you want to retrieve.

版本

0,1

方法

获取

参数

rev要检索的文件的修订版。默认值为最新版本。

rev The revision of the file to retrieve. This defaults to the most recent revision.

返回

指定文件的内容在请求的版本中。

The specified file's contents at the requested revision.

HTTP响应在x-dropbox-metadata标头中包含JSON格式的内容元数据。

The HTTP response contains the content metadata in JSON format within an x-dropbox-metadata header.

错误

404在指定路径下找不到文件,或在指定转速下找不到文件。

404 The file wasn't found at the specified path, or wasn't found at the specified rev.

注意

此方法还支持HTTP范围检索请求,以允许检索部分文件内容。`

This method also supports HTTP Range Retrieval Requests to allow retrieving partial file contents.`

Done

这篇关于如何上传到Dropbox公用文件夹并获取公用URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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