Files upload / download.

The Python 'Requests' library is a neat, user-friendly HTTP module and one of the most popular packages as it's widely used for downloading and uploading files on the web. The Requests package isn’t part of Python’s standard library at least at the moment and should be installed by pip install requests.

Download and upload files with Python.

Two simple but still useful use cases below show examples of downloading MP3 file from the WEB and uploading text file on the free server.

Downloading MP3 file from Internet:

import requests

url = ""

req = requests.get(url)
content = req.content

with open('sample1.mp3', 'wb') as file:

print('MP3 file is downloaded !!!')

OUT: MP3 file is downloaded !!!

Uploading text file on the free web server:

import requests

url = ""

file = open('textfile.txt', 'rb')

req =, files={"upfile":file})

#You can display HTML response
# print(req.text)

print("You've uploaded a file.")

OUT: You've uploaded a file.

See also related topics: