0
Android 드라이브에서 파일을 업로드하고 Google 드라이브에서 공유하려고합니다. 파일 ID와 리소스 ID를 얻을 수 있습니다. 이제 링크가있는 사용자가 액세스 할 수 있도록 공개하려고합니다. 프로그래밍 방식으로 어떻게합니까?Google 드라이브에 내 파일을 공개하고 싶습니다.
Android 드라이브에서 파일을 업로드하고 Google 드라이브에서 공유하려고합니다. 파일 ID와 리소스 ID를 얻을 수 있습니다. 이제 링크가있는 사용자가 액세스 할 수 있도록 공개하려고합니다. 프로그래밍 방식으로 어떻게합니까?Google 드라이브에 내 파일을 공개하고 싶습니다.
사용 Permissions.create 및 파일에 "사람"의 종류를 설정합니다. 나는 이미 그렇게 시도
String fileId = "1sTWaJ_j7PkjzaBWtNc3IzovK5hQf21FbOw9yLeeLPNQ";
JsonBatchCallback<Permission> callback = new JsonBatchCallback<Permission>() {
@Override
public void onFailure(GoogleJsonError e,
HttpHeaders responseHeaders)
throws IOException {
// Handle error
System.err.println(e.getMessage());
}
@Override
public void onSuccess(Permission permission,
HttpHeaders responseHeaders)
throws IOException {
System.out.println("Permission ID: " + permission.getId());
}
};
BatchRequest batch = driveService.batch();
Permission userPermission = new Permission()
.setType("user")
.setRole("writer")
.setEmailAddress("[email protected]");
driveService.permissions().create(fileId, userPermission)
.setFields("id")
.queue(batch, callback);
Permission domainPermission = new Permission()
.setType("domain")
.setRole("reader")
.setDomain("example.com");
driveService.permissions().create(fileId, domainPermission)
.setFields("id")
.queue(batch, callback);
batch.execute();
: 다음은 Manage Sharing in Drive 가이드에서 코드입니다. 이 오류 메시지는 다음과 같습니다. null 객체 참조에서 'com.google.api.client.googleapis.batch.BatchRequest com.google.api.services.drive.Drive.Batch()'가상 메소드를 호출하려고 시도했습니다. 어떻게해야합니까? –