【发布时间】:2019-03-14 06:27:58
【问题描述】:
现在 google drive api 已被弃用,所以我集成了他们的新 Drive REST API。在我的应用程序中,我想显示文件选择器以从谷歌驱动器中选择文档/图像。 我用过他们的样本: https://github.com/gsuitedevs/android-samples/blob/master/drive/deprecation/app/src/main/java/com/google/android/gms/drive/sample/driveapimigration/MainActivity.java
private void openFileFromFilePicker(Uri uri) {
if (mDriveServiceHelper != null) {
Log.d(TAG, "Opening " + uri.getPath());
mDriveServiceHelper.openFileUsingStorageAccessFramework(getContentResolver(), uri)
.addOnSuccessListener(nameAndContent -> {
String name = nameAndContent.first;
String content = nameAndContent.second;
mFileTitleEditText.setText(name);
mDocContentEditText.setText(content);
// Files opened through SAF cannot be modified.
setReadOnlyMode();
})
.addOnFailureListener(exception ->
Log.e(TAG, "Unable to open file from picker.", exception));
}
}
现在我想将所选文件上传到我的服务器上,因为我需要一个 fileID,但在 onActivityResult 我只能访问文件名和内容。所以请帮助我并建议我任何解决方案。我如何将选定的简历文件或图像从谷歌驱动器上传到我的服务器。
【问题讨论】:
标签: android google-drive-android-api