Skip to content

Instantly share code, notes, and snippets.

@scubamut
Created December 24, 2024 15:42
Show Gist options
  • Select an option

  • Save scubamut/fcba31cf95843a8f39baaf3708a374b4 to your computer and use it in GitHub Desktop.

Select an option

Save scubamut/fcba31cf95843a8f39baaf3708a374b4 to your computer and use it in GitHub Desktop.
import requests
import io
FILE_ID = '1e8hAGdDC2hAbEnosh1Odo9tAj_Wlzl8H'
LOCAL_FILE_NAME = 'TA_Lib-0.4.26-cp310-cp310-linux_x86_64.whl'
def download_public_file(file_id, local_file_name):
url = f'https://drive.google.com/uc?id={file_id}'
try:
response = requests.get(url, stream=True)
response.raise_for_status() # Raise an exception for bad status codes
with open(local_file_name, 'wb') as file:
for chunk in response.iter_content(chunk_size=8192):
file.write(chunk)
print(f"File downloaded successfully to '{local_file_name}'")
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == '__main__':
download_public_file(FILE_ID, LOCAL_FILE_NAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment