Skip to content

Instantly share code, notes, and snippets.

@korakot
Created November 15, 2017 08:40
Show Gist options
  • Save korakot/e7f04fa7bd3a8a67b729da279ab1713a to your computer and use it in GitHub Desktop.
Save korakot/e7f04fa7bd3a8a67b729da279ab1713a to your computer and use it in GitHub Desktop.
Google colab file upload/download
files.download('example.txt') # from colab to browser download
from google.colab import files
uploaded = files.upload() # then browse, select the files. It's then uploaded
# uploaded is now a dict containing "filename" -> Content
@nicogaspa
Copy link

Follow this tutorial to connect your drive storage to the colab space:
https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d

@utksh
Copy link

utksh commented Jul 6, 2018

What is the directory in which the file get uploaded when i upload it with

from google.colab import files
files.upload()

@TiborUdvari
Copy link

It's just added to the current directory

@secsilm
Copy link

secsilm commented Aug 17, 2018

@008karan You can compress them into a zip-like file first and then upload it.

@neomatrix369
Copy link

Would this work in Jupyter notebook?

@dhiren-hamal
Copy link

dhiren-hamal commented Jun 4, 2019

You can download files or folder from colab like this:
from google.colab import files
#For the folder you have to zip it first and can only download later on
!zip -r bears.zip data/bears
#Download files
files.download('bears.zip')

@veeeencedamico2
Copy link

You can download files or folder from colab like this:
from google.colab import files
#For the folder you have to zip it first and can only download later on
!zip -r bears.zip data/bears
#Download files
files.download('bears.zip')

What if I wanted to use this piece of code in a python source?

@AhabbscienceStudioPak
Copy link

AhabbscienceStudioPak commented May 17, 2020

You can download files or folder from colab like this:
from google.colab import files
#For the folder you have to zip it first and can only download later on
!zip -r bears.zip data/bears
#Download files
files.download('bears.zip')

Thanks, I was just looking ways to download a whole folder/sub repository from colab.

@sonu275981
Copy link

Good Work......keep it up

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