Reputation: 169
I'm wondering if there is a library that would enable me to upload a file to a remote server via ftp. I know there is ftplib, but from what i can tell, it only allows uploading from your own files. So if I had a URL like, https://vignette.wikia.nocookie.net/disney/images/d/db/Donald_Duck_Iconic.png , could I make a program to directly download/upload this to my ftp server. Instead of first having to download it to my own computer, then upload it to the server.
Sorry for formatting I'm on mobile.
Upvotes: 0
Views: 568
Reputation: 728
You can use requests to download the file, and put the content into a BytesIO for upload:
from io import BytesIO
import requests
url = 'https://vignette.wikia.nocookie.net/disney/images/d/db/Donald_Duck_Iconic.png'
response = requests.get(url)
f = BytesIO(response.content)
Then, f
is a file-like object that is suitable for FTP.storbinary.
Upvotes: 1