【问题标题】:PCloud Api Uploadfile with pythonPCloud Api Uploadfile 与 python
【发布时间】:2016-09-11 09:54:25
【问题描述】:

我尝试使用以下 URL 上传带有 pcloud (https://api.pcloud.com/uploadfile?) 的文件:

https://api.pcloud.com/uploadfile?username=myemail&password=mypassword&path=/&filename=myfile

但我收到以下错误:

{
  "result": 0,
  "metadata": [

  ],
  "checksums": [

  ],
  "fileids": [

 ]
}

这是我在 Windows 上的示例代码:

import requests
import json

username = 'test@gmail.com'
password = 'mypassword'
myfile   = r'd:\MUSIC\Get Lucky\01 - Border Reiver.mp3'
url      = "https://api.pcloud.com/uploadfile?username=%s&password=%s&path=/&filename=%s" % (username, password, myfile)
get = requests.get(url)

print json.loads(get.text)

【问题讨论】:

  • 所以,我们实际上需要更多信息。您的代码示例可能非常有用。
  • 我已经编辑了我的问题,任何想法,谢谢

标签: python https pcloud


【解决方案1】:

您的代码需要一个带有 Keep-Alive 标头的 POST。

import requests
session = requests.Session()
files = {'01 - Border Reiver.mp3': open('d:\MUSIC\Get Lucky\01 - Border Reiver.mp3', 'rb')}
data = {'username': 'test@gmail.com', 'password': 'mypassword'}
post = session.post('https://api.pcloud.com/uploadfile', files=files, data=data)
print(post.json())

如需更详细的示例,您可以查看 pcloud API 的 Python 包装器。它在 PyPi 和 github 上可用。 https://pypi.python.org/pypi/pcloud

【讨论】:

    猜你喜欢
    • 2023-01-02
    • 2019-05-11
    • 2021-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多