Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Image from URL to Dropbox
-
I am trying to write a script to upload an image at a public url to my Dropbox. I already have several other scripts uploading text files to Dropbox but he image isn't working. Any ides based on the code below?
import Image import photos import sys import webbrowser import console import urllib from urllib import urlopen from io import BytesIO from DropboxLogin import get_client dropbox_client = get_client() import clipboard import keychain import time import httplib url = 'http://313e5987718b346aaf83-f5e825270f29a84f7881423410384342.r78.cf1.rackcdn.com/Pythonista_-_screenshotscopy.PNG' img = urlopen(url).read() buffer = Image.open(BytesIO(img)) img.save(buffer, 'PNG') buffer.seek(0) response = dropbox_client.put_file('/Public/test.png', buffer)
-
import dropboxlogin, requests url = 'http://313e5987718b346aaf83-f5e825270f29a84f7881423410384342.r78.cf1.rackcdn.com/Pythonista_-_screenshotscopy.PNG' dropbox_file_name = '/Public/test.png' image_buffer = requests.get(url).content #image_buffer.seek(0) # this line is not required!?! dropbox_client = dropboxlogin.get_client() response = dropbox_client.put_file(dropbox_file_name, image_buffer) print(response)
... or ...
import dropboxlogin, requests url = 'http://313e5987718b346aaf83-f5e825270f29a84f7881423410384342.r78.cf1.rackcdn.com/Pythonista_-_screenshotscopy.PNG' dropbox_file_name = '/Public/test.png' dropbox_client = dropboxlogin.get_client() response = dropbox_client.put_file(dropbox_file_name, requests.get(url).content) print(response)