2016-12-20 3 views
0

pyDrive를 사용하여 Google 드라이브에 파일을 업로드하고 있습니다. 특정 폴더에 파일을 업로드 할 수 있습니다.업로드 된 파일을받는 사람에게 Google 드라이브에 메모를 보내는 방법은 무엇인가요?

from pydrive.auth import GoogleAuth 
from pydrive.drive import GoogleDrive 

gauth = GoogleAuth() 
gauth.LocalWebserverAuth() 

drive = GoogleDrive(gauth) 

file1 = drive.CreateFile({'title': 'myfile.txt', 'parents': [{"kind": "drive#fileLink","id": {FOLDER_ID}}]}) 
file1.SetContentFile('myfile.txt') 
file1.Upload() 

어떻게 다른 사람과 업로드 된 파일을 공유하고 pyDrive 또는 공식 Google 드라이브 REST API를 사용하여받는 사람 중 하나에 메모를 보낼 수 ?

+1

나는 이것이 무엇을 찾고 있는지 믿습니다 : https://developers.google.com/drive/v3/web/manage-sharing 그것은 파이썬에서도 권한 설정을위한 코드를 가지고 있습니다. –

답변

1

이 내용은 InsertPermission을 통해 pydrive에서 사용할 수 있습니다.

사용자 또는 그룹 이메일 주소에 대한 권한을 만드는 행위는 기본적으로 해당 사용자 또는 그룹에게 공유 이메일을 보냅니다.

자세한 내용은 드라이브 API 설명서 creating permissions을 참조하십시오.

0

Handling special metadata, 특히 InsertPermission을 사용하여 수행 할 수 있습니다.

당신과 같이 (자신의 이메일 주소를 사용하여) 사용자와 문서를 공유 할 수 있습니다 : 당신은 사용자의 쓰기 권한을 부여하려면

# Add a read permission for the user with the specified email address. 
permission = file1.InsertPermission({ 
         'type': 'user', 
         'value': '<[email protected]>', 
         'role': 'reader'}) 


# You can check which permission settings a file has: 
print(file1['permissions']) 

writerreader를 교체합니다.

InsertPermissionAPI docs 공식에 설명 된 모든 플래그를 허용합니다.

참고 : PyDrive는 Google 드라이브 API의 v2을 사용합니다.