简体   繁体   English

如何使用 python 从 Dropbox 获取文件并上传到我的服务器

[英]How to get file from dropbox and upload on my server by using python

I am working on application where I am giving a functionality to user where they can signin from dropbox by using my application but when I am trying to get the file from Dropbox I am unable to do it.我正在开发应用程序,我正在向用户提供功能,他们可以使用我的应用程序从 Dropbox 登录,但是当我尝试从 Dropbox 获取文件时,我无法做到这一点。 When user choose the desired file from dropbox and click on choose and then nothing happen.当用户从保管箱中选择所需的文件并单击选择时,什么也没有发生。 Can anyone please help out either is it possible to do it or not?任何人都可以帮忙,是否可以这样做? If yes, how can we do it?如果是,我们该怎么做? I am at beginner level.我处于初学者水平。 Please help me out and explain the whole process to do it in detail.请帮助我并详细解释整个过程。

在此处输入图像描述

Are you using public Dropbox files?您在使用公共 Dropbox 文件吗?

Then you just need to fetch the item by URL and download it.然后你只需要通过 URL 获取项目并下载它。 If this happens in a browser tool, you'll need JavaScript and not Python to download it.如果在浏览器工具中发生这种情况,您需要 JavaScript 而不是 Python 来下载它。

Or you leave out JS and just use Python to render an HTML page where a button is for a Dropbox file and clicking the button triggers a download of the file.或者您忽略 JS,只使用 Python 来呈现 HTML 页面,其中一个按钮用于 Dropbox 文件,单击该按钮会触发文件下载。 That is a generic HTML task you can search for.这是您可以搜索的通用 HTML 任务。

If you need access to sign in Dropbox and view private files, consider using a Python library built around Dropbox.如果您需要访问以登录 Dropbox 并查看私人文件,请考虑使用围绕 Dropbox 构建的 Python 库。

See the Python Dropbox guide.请参阅 Python Dropbox 指南。 Are you using a library like that?你在用这样的图书馆吗? Please share as your question was vague.请分享,因为您的问题含糊不清。

https://www.dropbox.com/developers/documentation/python# https://www.dropbox.com/developers/documentation/python#

Also please share an explanation of what your logic is or a small code snippet.还请分享您的逻辑或小代码片段的解释。 I can't see what you are doing yet so I don't know where you are missing something or making a mistake.我还看不到你在做什么,所以我不知道你在哪里遗漏了什么或犯了错误。

From the screenshot, I see you're using the Dropbox Chooser .从屏幕截图中,我看到您正在使用Dropbox 选择器 That's a pre-built way to let your end-users select files from their Dropbox accounts and give them to your app.这是一种预先构建的方式,可以让您的最终用户 select 文件从他们的 Dropbox 帐户中,并将它们提供给您的应用程序。

Make sure you implement the success and cancel callback methods as documented there for the Chooser .确保您实现了successcancel回调方法,如那里为选择器记录的那样

In the success callback, you'll get the information for the selected file(s).success回调中,您将获得所选文件的信息。 That occurs in JavaScript in the browser though, so if you need that on your server, you'll need to write some JavaScript to send that up to your server, eg, via an AJAX call or a form or whatever means you use in your app.但是,这发生在浏览器中的 JavaScript 中,因此,如果您在服务器上需要它,则需要编写一些 JavaScript 以将其发送到您的服务器,例如,通过 ZA34A6659BCEAE779F28185E757ABCA 调用或您使用的任何方式应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM