Skip to content

Instantly share code, notes, and snippets.

@nkpro2000sr
Last active August 26, 2020 21:57
Show Gist options
  • Save nkpro2000sr/9b74ed4fcc41556a79eb8a0d3f6bcc03 to your computer and use it in GitHub Desktop.
Save nkpro2000sr/9b74ed4fcc41556a79eb8a0d3f6bcc03 to your computer and use it in GitHub Desktop.
To download large files directly into google drive (later we can split and download)
Display the source blob
Display the rendered blob
Raw
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"ToDownload.ipynb","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"}},"cells":[{"cell_type":"code","metadata":{"id":"9deDxQoXyBx9","colab_type":"code","colab":{}},"source":["from google.colab import drive\n","drive.mount('/content/drive')\n","!ln -nfs 'drive/My Drive/Colab Notebooks' 'CoN'\n","ROOT_PATH = 'CoN' #'drive/My Drive/Colab Notebooks'\n","!pwd && ls -ial"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"5BiszSs761LX","colab_type":"code","colab":{}},"source":["import os\n","import requests\n","url = input('Enter URL >')\n","filename = input('Enter File name >')\n","filepath = os.path.join(ROOT_PATH,filename)\n","with open(filepath,'wb') as file:\n"," file.write(requests.get(url).content)\n","print('Done :)')"],"execution_count":null,"outputs":[]},{"cell_type":"markdown","metadata":{"id":"-NcVfIl_A3FM","colab_type":"text"},"source":["### To split large files into multiple files\n","```bash\n","split -b 1M path/to/file path/to/file_ # to split file into file_*\n","# 1024 bytes prefix\n","```\n","### To merge back\n","```bash\n","cat path/to/file_* > path/to/file # to merge files back\n","```\n","<br>\n","\n","#### Save md5 hash of original file to verify after merge\n","```bash\n","cd path/to/dir/ && md5sum file > file.md5\n","```\n","#### To check merged file\n","```bash\n","cd path/to/dir/ && md5sum -c file.md5\n","```"]}]}
@nkpro2000sr
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment