- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在我的树莓派上使用来自 github 的“Dropbox-Uploader”脚本来将视频上传到我的 Dropbox 帐户。
https://github.com/andreafabrizi/Dropbox-Uploader
它工作得很好,但现在我希望我的树莓派能够在 dropbox 上自动上传视频。为此我编写了 python 脚本
import os
path="/tmp/motion/"
def upload_files():
if not os.path.exists(path):
return
os.stdir(path)
for files in os.listdir("."):
if files.endswith(".avi"):
cmd = "/home/pi/dropbox_uploader.sh upload " + path + files
os.system(cmd)
os.system("sudo rm /tmp/motion/" + files)
if _name_ == "_main_":
upload_files()
并将其设置为 cronjob 但它不起作用,它没有在我的帐户上上传任何内容。任何帮助将不胜感激
最佳答案
我用许多不同的脚本编写了一个脚本,最后它工作得很好。首先要安装一些东西:-您进行完整的更新、升级我现在不知道所有不必要的步骤,但我会将其全部写在这里,您可以自己编辑它 - 但它仍然有效并且不会对您的设备造成任何损害。
第 1 步
逐步将其复制并粘贴到您的终端:
sudo apt-get install python3-picamera
sudo apt-get install python3-pip
sudo apt-get install python-pip
pip3 install unicornhat
pip install unicornhat
sudo apt-get update
sudo apt-get upgrade -f
sudo apt-get upgrade
sudo apt-get install pip
sudo pip install dropbox
第 2 步
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh
chmod +x dropbox_uploader.sh
./dropbox_uploader.sh
-您还需要从 Dropbox.com 获取 Accesstoken(https://www.dropbox.com/developers/apps)
我不知道是否有必要,但你需要在 MyApps 中有一个文件,并将其命名为“Raspi-upload”+ 我的设置里面:状态: 开发开发用户:只有你权限类型:完整 Dropbox允许隐式授予:允许
-然后你就有了你的 key :
每 <10 秒拍摄一张照片并将其上传到手机上的 Dropbox 应用。
上传完成后拍摄的照片将被删除,因此您不会浪费 SD 卡上的空间。
这是脚本:#######TOP
#!/usr/bin/env python3.4
import dropbox
from dropbox.exceptions import ApiError, AuthError
import time
import datetime
import picamera
import sys, os
from time import sleep
import dropcamloop1
# Authorisation token
TOKEN = 'HERE IS YOUR ACCESS TOKEN'
# Format photo will be saved as e.g. jpeg
PHOTOFORMAT = 'jpeg'
# Create a camera object and capture image using generated filename
def camCapture(filename):
with picamera.PiCamera() as camera:
camera.resolution = (1920, 1080)
print("Photo: %s"%filename + "." + PHOTOFORMAT)
time.sleep(2)
camera.capture(filename + '.' + PHOTOFORMAT, format=PHOTOFORMAT)
print("Photo captured and saved ...")
return filename + '.' + PHOTOFORMAT
# Generate timestamp string generating name for photos
def timestamp():
tstring = datetime.datetime.now()
print("Filename generated ...")
return tstring.strftime("%Y%m%d_%H%M%S")
#return tstring.strftime("image")
# Upload localfile to Dropbox
def uploadFile(localfile):
# Check that access tocken added
if (len(TOKEN) == 0):
sys.exit("ERROR: Missing access token. "
"try re-generating an access token from the app console at dropbox.com.")
# Create instance of a Dropbox class, which can make requests to API
print("Creating a Dropbox object...")
dbx = dropbox.Dropbox(TOKEN)
# Check that the access token is valid
try:
dbx.users_get_current_account()
except AuthError as err:
sys.exit("ERROR: Invalid access token; try re-generating an "
"access token from the app console at dropbox.com.")
# Specify upload path
uploadPath = '/' + localfile
# Read in file and upload
with open(localfile, 'rb') as f:
print("Uploading " + localfile + " to Dropbox as " + uploadPath + "...")
try:
dbx.files_upload(f.read(), uploadPath)
except ApiError as err:
# Check user has enough Dropbox space quota
if (err.error.is_path() and
err.error.get_path().error.is_insufficient_space()):
sys.exit("ERROR: Cannot upload; insufficient space.")
elif err.user_message_text:
print(err.user_message_text)
sys.exit()
else:
print(err)
sys.exit()
# Delete file
def deleteLocal(file):
os.system("rm " + file)
print("File: " + file + " deleted ...")
def main():
# Generate name for file based on current time
filename = timestamp()
# Capture photo
file = camCapture(filename)
# Upload file
uploadFile(file)
# Delete local file
deleteLocal(file)
print("Done")
#time.sleep(4)
#x=0
#while(x <4):
#os.execv(sys.executable, ['/home/pi/Adafruit_Python_DHT/examples/dropcamloop1.py'])
if __name__ == '__main__':
main()
time.sleep(4)
x=3
while(x <4):
#os.execv(sys.executable, [sys.executable] )
execfile('dropcamloop.py')
else:
start ['dropcamloop1.py']
###END = dropcamloop1.py 是同一个文件,只是名称不同。
如果您有任何问题,也许我可以帮助您,但目标不是 100% 确定。
关于python - 从树莓派自动上传到dropbox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34005143/
我想将文件从服务器推送到我自己的 Dropbox。我可以在服务器上存储 API token 甚至(虽然不情愿)帐户密码。我不想在服务器上安装 Dropbox。 我还需要在 Dropbox 开发者主页创
有没有办法通过 Dropbox 选择器获取用于共享文档的短网址? 最佳答案 不,不像 Dropbox Core API , Dropbox Chooser不提供获取短 URL 的能力。 当然,这并不妨
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 5年前关闭。 Improve this questi
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a software
我正在尝试开发一个使用某种云存储的应用程序。我认为 dropbox 非常适合使用。我已经有了我的应用 key 和应用 key 。 在他们为 DBRoulette 提供的示例中,您通过外部 GUI 登录
我正尝试在我的网络应用程序中迁移到 dropbox-api v2。目前我有打开弹出窗口的实现,用户连接到他/她的保管箱,我得到 token 。我用它来访问用户在后续步骤中在 Dropbox.choos
我正尝试在我的网络应用程序中迁移到 dropbox-api v2。目前我有打开弹出窗口的实现,用户连接到他/她的保管箱,我得到 token 。我用它来访问用户在后续步骤中在 Dropbox.choos
据我所知Zapier基本使用Webhooks将服务相互链接。支持的服务之一是 Dropbox .但是 Dropbox(仍然)不支持 webhook。 (即:Dropbox 无法向选择的任意 webho
Dropbox 是否可以在文件更改时发出通知,即新上传的到达或文件已更改。 最佳答案 正如 Kannan 所指出的,有一个名为 /delta 的新 API 端点。这比轮询或 RSS 更好。 这也可以与
Dropbox Rest api,在函数metatada中有一个名为“hash”的参数https://www.dropbox.com/developers/reference/api#metadata
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我需要用户授予我的应用访问他们 Dropbox 的权限,但我非常希望他们不必离开我的网站然后再回来。我所知道的身份验证 API 要求用户登录到他们的 Dropbox 帐户,并且他们在 Dropbox
是否可以在拥有该应用程序的所有用户帐户之间共享应用程序保存的数据? 最佳答案 这不是受支持的操作;数据存储 API 实际上是作为本地存储的同步替代品,而不是作为访问单个共享数据库的方式。 更新:现在支
问题是如何在中列出最近修改过的文件保管箱 帐户使用他们的 API? 保管箱 web UI 可以显示 recently changed files 的摘要,但我在他们的 API documentatio
如何使用 dropbox api 编辑文件或文件夹名称? 我正在使用这个引用: https://www.dropbox.com/developers/core/docs 还有什么吗? 这可能吗? 最佳
我正在尝试使用他们的 java API(版本 2-beta-4)将一些文件上传到保管箱,但其中一些文件具有相同的名称。 我想知道的是:我发送文件(例如“file.txt”)到保管箱的原因是什么,该文件
在the document of Dropbox Chooser我们可以从 files[0].link 获取共享页面 url,但我们需要直接下载链接。我如何获得它? 最佳答案 我在 the forum
我正在尝试将一些文件从一个文件夹移动到另一个文件夹。 这是我的 curl 请求: curl -X POST https://api.dropboxapi.com/2/files/move \ --
我有一个网络应用程序,用户可以在其中上传他的 Logo 图片 使用 dropbox api 我可以将文件保存到一个很棒的 dropbox 文件夹中 但是我想获取下载链接,以便使用我的 angular
我需要一个简单的网络表单,它还可以让人们上传一些 pdf。我想我可以做的(因为上传文件的大小和数量)是将这个应用程序的后端绑定(bind)到我的 Dropbox 帐户或我的 box.com 帐户。两种
我是一名优秀的程序员,十分优秀!