I need to to set the permissions for a GDrive file that i am inserting. Rather than change the permissions after its inserted as a separate call, it makes sense to set the permissions right when its inserted. I need a link to allow others to download, but not edit.
it inserts fine but does not allow anyone with the link to access... Hmmmm
I have done my google-homework and I have seen the SO quezz and ans at: Set file sharing level to 'Anyone with the link' through Google Drive API but still no luck doin it in one deft call
I cant believe i need to have a separate service.permissions().insert
...so, can anyone see what i'm missing / point me in the right direction?
Here's the relevant snip of my code:
def upToGDrive (readPath, title, filename, parent_id = None):
os.chdir(readPath) #change directory to find right file
from apiclient.http import MediaFileUpload
mime_type = 'application/octet-stream'
description = 'yeah baby!'
media_body = MediaFileUpload(filename, mimetype=mime_type, resumable=True)
body = {
'title': title,
'description': description,
'mimeType': mime_type,
'value': 'none',
'type': 'anyone',
'role': 'reader',
'withLink': 'true'
}
# Set the parent folder, if necessary
if parent_id:
body['parents'] = [{'id': parent_id}]
try:
file = drive_service.files().insert(body=body,media_body=media_body).execute()
return