从 python 脚本上传文件到我的 Dropbox

2022-01-09 00:00:00 python upload dropbox

问题描述

我想将我的 python 脚本中的文件自动上传到我的 Dropbox 帐户.我无论如何都找不到只用一个用户/通行证来做到这一点.我在 Dropbox SDK 中看到的一切都与具有用户交互的应用程序有关.我只想做这样的事情:

I want to upload a file from my python script to my dropbox account automatically. I can't find anyway to do this with just a user/pass. Everything I see in the Dropbox SDK is related to an app having user interaction. I just want to do something like this:

https://api-content.dropbox.com/1/files_put//?user=me&pass=blah

https://api-content.dropbox.com/1/files_put//?user=me&pass=blah


解决方案

重要提示:此答案已弃用,因为 Dropbox 现在使用 v2 API.
当前API版本解决方案见@SparkAndShine的回答

Important Note: this answer is deprecated since dropbox uses v2 API now.
See the answer of @SparkAndShine for current API version solution

感谢@smarx 的上述回答!我只是想为其他试图这样做的人澄清一下.

Thanks to @smarx for the answer above! I just wanted to clarify for anyone else trying to do this.

  1. 当然要先安装 dropbox 模块,pip install dropbox.

在应用程序控制台"中以您自己的 Dropbox 帐户创建应用程序.(https://www.dropbox.com/developers/apps)

Create an app under your own dropbox account in the "App Console". (https://www.dropbox.com/developers/apps)

为了记录,我使用以下内容创建了我的应用程序:

Just for the record I created my App with the following:

一个.应用类型为Dropbox API APP".

a. App Type as "Dropbox API APP".

b.数据访问类型为文件和数据存储"

b. Type of data access as "Files & Datastores"

c.文件夹访问权限为我的应用需要访问 Dropbox 上已有的文件".(即:权限类型为Full Dropbox".)

c. Folder access as "My app needs access to files already on Dropbox". (ie: Permission Type as "Full Dropbox".)

然后点击生成访问令牌"按钮并剪切/粘贴到下面的python示例中代替<auth_token>:

Then click the "generate access token" button and cut/paste into the python example below in place of <auth_token>:

相关文章