Android 용 Google 드라이브 API를 사용해 봤는데 약간의 문제가 발생했습니다. 필자는 모든 기기에서 앱 데이터를 저장하고 동기화하는 App Folder에 관심이 있습니다. 특정 파일 이름의 파일이 app 폴더에 있는지 쿼리 할 수 있습니다. 나는DriveContents.getOutputStream()에 의해 반환 된 OutputStream이 예상대로 작동하지 않는 이유는 무엇입니까?
driveFile.open(mGoogleApiClient,
DriveFile.MODE_WRITE_ONLY,
new DownloadProgressListener() {...})
.setResultCallback(...);
를 통해
driveFile = metadata.getDriveId().asDriveFile();
내가 파일을 열 수 있습니다를 통해 파일을 얻을 수 있습니다 그리고 나중에 콜백에 내가와의 OutputStream 얻을 수 있습니다 :
OutputStream outputStream = dcr.getDriveContents().getOutputStream();
그러나 문제가 있다는 것입니다 경우 I 그 OutpustStream에 쓰려고 아무것도 파일에 기록되지 않습니다. 다음과 같은 코드를 사용했습니다.
OutputStream outputStream = result.getDriveContents().getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
try {
writer.write("Just some strinh I want to save to Google Drive.");
} catch (IOException e) {
throw new RuntimeException(e);
}
Status status = dcr.getDriveContents().commit(mGoogleApiClient, null).await();
이 OutputStream을 사용하면 GoogleDrive에 아무 것도 기록되지 않습니다. 하지만 https://developers.google.com/drive/android/files#making_modifications 코드를 사용하면 예상대로 작동합니다.
A는 참조 용 구글에서 해당 코드의 조각을 복사 예상대로
try {
ParcelFileDescriptor parcelFileDescriptor = contents.getParcelFileDescriptor();
FileOutputStream fileOutputStream = new FileOutputStream(parcelFileDescriptor
.getFileDescriptor());
Writer writer = new OutputStreamWriter(fileOutputStream);
writer.write("hello world");
} catch (IOException e) {
e.printStackTrace();
}
왜() 작동하지 DriveContents.getOutputStream에 의해 accesible의 OutputStream는 무엇입니까? 왜 그것이 제공되는 것입니까? 또는 나는 무엇인가 놓치고 있냐? Google Play 서비스 라이브러리의 버전은 r29입니다.