I have a public link for a GoogleDrive folder: https://drive.google.com/drive/folders/19RUYQNOzMJEA-IJ3EKKUf0qGyyOepzGk?usp=sharing
And I want to access the content in a colab notebook. I want anyone who opens the notebook to be able to access the folder, so without mounting my own drive. Other answers like Downloading public files in Google Drive (Python) seem to suggest slicing the ID. I tried following the instructions https://towardsdatascience.com/3-ways-to-load-csv-files-into-colab-7c14fcbdcb92
link= 'https://drive.google.com/drive/folders/19RUYQNOzMJEA-IJ3EKKUf0qGyyOepzGk?usp=sharing'
fluff, id = link.split('=')
print (id)
however my id is just 'sharing'
EDIT CODE STILL NOT WORKING
I have changed the permission of filesharing like so
and then run the code:
from google.colab import auth
auth.authenticate_user() # must authenticate
'''list all ids of files directly under folder folder_id'''
def folder_list(folder_id):
from googleapiclient.discovery import build
gdrive = build('drive', 'v3').files()
res = gdrive.list(q="'%s' in parents" % folder_id).execute()
return [f['id'] for f in res['files']]
'''download all files from a gdrive folder to current directory'''
def folder_download(folder_id):
for fid in folder_list(folder_id):
!gdown -q --id $fid
link='https://drive.google.com/drive/folders/1I6FwS5qB2bIwoPE4ueu8ZNH3upBqMB7S?usp=sharing'
folder_id="1I6FwS5qB2bIwoPE4ueu8ZNH3upBqMB7S"
folder_download(folder_id)
but get This error:
Permission denied: https://drive.google.com/uc?id=1AiNvRugUOWIthoSdBMBB5p5GLpyj6_Vd
Maybe you need to change permission over 'Anyone with the link'?
However I have changed the permission to 'anyone with the link
EDIT 2: making sure all folders have shareable active Following Korakot Chaovavanich comment, I have made sure every file/folder is shareable:
the url link refers to this folder:
which has only one file, also shareable:
however running the code mentioned in EDIT 1: I get this error:
Permission denied: https://drive.google.com/uc?id=1AiNvRugUOWIthoSdBMBB5p5GLpyj6_Vd
Maybe you need to change permission over 'Anyone with the link'?