I'm trying to upload an image file to a folder in my drop box. when i request the Authentication i get a response but i'm not able to upload the file. this is how i do it:
import requests
header = {
'Authorization': 'Bearer <Auth_token>',
'Dropbox-API-Arg': '{"path": "/home/Pics","mode": "add","autorename": true,"mute": false,"strict_conflict": false}',
'Content-Type': 'application/octet-stream'
}
data = open(r'C:\Users\Username\Desktop\1980.jpg', 'rb')
response = requests.post('https://content.dropboxapi.com/2/files/upload', headers=header, data=data)
I get a 200 response code but when i check my folder there is nothing in it. What am i doing wrong?
response.json() is:
{'name': 'Pics (2)', 'path_lower': '/home/pics (2)', 'path_display': '/home/Pics (2)', 'id': 'id:OVRvFsnXnNAAAAAAAAAAGA', 'client_modified': '2020-06-21T12:28:19Z', 'server_modified': '2020-06-21T12:28:20Z', 'rev': '015a89742f0558300000001d50ef150', 'size': 567987, 'is_downloadable': True, 'content_hash': '11ffddd183c5315d4195091c8b81f8efd57d3283d460d5dd6d5e782ea2616458'}
Ok i found out what the problem was, In fact the file was actually uploaded but with an unknown format!
In the header parameters "path": "/home/Pics"
"Pics" should be name of the file you want it to be saved as, like "path": "/home/MyImage.jpg"