I am working in a project that have to upload multiple audio files (.amr) to google drive to a specific folder. Now I am going through "startIntentSender" method to show a picker to choose a folder in drive. For a single file it is working fine, But I need to send multiple files at a time without any picker and I have to send that to a specific folder that I need to specify in program. I have searched a lot but I am getting confused. Now Google Drive Api is deprecated. Is there any method for multiple uploading ?
Drive.DriveApi.newDriveContents(mGoogleApiClient)
.setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
Log.i(TAG, "Failed to create new contents.");
return;
}
OutputStream outputStream = result.getDriveContents().getOutputStream();
try {
FileInputStream fileInputStream = new FileInputStream(mAllCallRecordFiles.get(i).getFilePath());
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} catch (IOException e1) {
Log.i(TAG, "U AR A MORON! Unable to write file contents.");
}
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setMimeType("audio/*")
.build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(mGoogleApiClient);
try {
startIntentSender(intentSender, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.i(TAG, "Failed to launch file chooser.");
}
}
})