accessing "Shared with me" with Colab

Leon Rai picture Leon Rai · Jan 24, 2019 · Viewed 23k times · Source

I want to get access to the files in the Google Drive's "Shared with me" directory.

In the Colab python notebook the following commands:

import os
from google.colab import drive
drive.mount('/content/drive')
!ls "/content/drive/My Drive"

work well for "My Drive" directory however

!ls "/content/drive/My Drive"

fails with

FileNotFoundError: [Errno 2] No such file or directory:

I am aware of the fact that I can add the folder to my drive manually and proceed (as mentioned in here), but I would like to have direct access to the shared folders for lets say I might need to automate the work with files that are shared with me real time.

I am also aware that same/similar problem exist with other cloud platforms like "OneDrive".

The questions are:

  1. if there is no straightforward way of doing it, is there at least a workaround?
  2. do the people I share my code with get access to my drive too?

Answer

Bob Smith picture Bob Smith · Jan 24, 2019

RE: Is there a work-around --

Load your shared files in the web UI, right click on the directory of interest, and select 'Add to my Drive'. Then, the folder will appear in /content/drive/My Drive as you hope.

For context, Drive isn't like a normal filesystem: files and directories can have multiple parents, thereby appearing in both your file list and the original owners.

RE: Will other users have access to Drive files? --

No, the notebook is a distinct object in Drive with distinct Drive permissions.