1

I have tried to upload a file with pcloud (https://api.pcloud.com/uploadfile?) using this URL:

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

But I get the following error:

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

  ],
  "checksums": [

  ],
  "fileids": [

 ]
}

this is my example code on my 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)
Jakub Muda
  • 6,008
  • 10
  • 37
  • 56
cumulus13
  • 96
  • 2
  • 11

1 Answers1

2

Your code would need a POST with a Keep-Alive header.

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())

For a more detailed example you might checkout out the Python wrapper for the pcloud API. It is available on PyPi and github. https://pypi.python.org/pypi/pcloud

Akhzar Farhan
  • 7
  • 1
  • 1
  • 6
Tom
  • 619
  • 6
  • 17