-
Notifications
You must be signed in to change notification settings - Fork 6k
Expand file tree
/
Copy pathaddFileToDrive.txt
More file actions
33 lines (24 loc) · 1.13 KB
/
addFileToDrive.txt
File metadata and controls
33 lines (24 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
ResultCallback<DriveContentsResult> contentsCallback = new ResultCallback<DriveContentsResult>() {
@Override
public void onResult(DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
// Handle error
return;
}
//providing metadata for the new file
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(nameOfFile) //provide nameoffile
.setMimeType("*/*") //set mime type
.build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(getGoogleApiClient());
try {
startIntentSenderForResult(intentSender, 1, null, 0, 0, 0);
} catch (SendIntentException e) {
// Handle the exception
}
}
};