Which MIME type to use to uploaddownload files with different extensions in Google Drive v3 from Android Studio

Which MIME type to use to uploaddownload files with different extensions in Google Drive v3 from Android Studio

Questions : Which MIME type to use to uploaddownload files with different extensions in Google Drive v3 from Android Studio

1914

Actually my scenario is:

I want to create a parent folder, then a sub in4codes_download folder and in that one I have further in4codes_download subfolders in which I have files of in4codes_download different extensions. This happens in my in4codes_download android local storage.

I managed to upload data using MIME type in4codes_download application/vnd.google-apps.spreadsheet and in4codes_download it is also downloading it in all folders in4codes_download respectively, but if I create a folder on in4codes_download google drive and upload files there from in4codes_download windows/ios, then in android, when I in4codes_download download data, it only downloads the file in4codes_download which is uploaded from my anddroid app.

But i want to download folders/files which in4codes_download ios/windows users have made asd well. So how in4codes_download do I achieve that?

 /** * Upload the file. */ public Task<Boolean> uploadFileToGoogleDrive(String subFolderId , String path) { // if (subFolderId.isEmpty()){ // Log.e(TAG, "uploadFileToGoogleDrive: folder id not present" ); // isFolderPresent().addOnSuccessListener(id -> subFolderId =id) // .addOnFailureListener(exception -> Log.e(TAG, "Couldn't create file.", exception)); // } return Tasks.call(mExecutor, () -> { Log.e(TAG, "uploadFileToGoogleDrive: path: "+path ); Log.e(TAG, "uploadFileToGoogleDrive: subFolderID: "+subFolderId ); java.io.File filePath = new java.io.File(path); File fileMetadata = new File(); fileMetadata.setName(filePath.getName()); fileMetadata.setParents(Collections.singletonList(subFolderId)); fileMetadata.setMimeType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); FileContent mediaContent = new FileContent("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filePath); File file = mDriveService.files().create(fileMetadata, mediaContent) .setFields("id") .execute(); System.out.println("File ID: " + file.getId()); return false; }); } // upload the file method end My Code for querying folders on cloud is: /** * Get list of all the folders present in Subfolder */ public Task<FileList> queryChildFolders() { if (subFolderId.isEmpty()){ Log.e(TAG, "uploadFileToGoogleDrive: Sub folder id not present" ); isSubFolderPresent().addOnSuccessListener(id -> subFolderId =id) .addOnFailureListener(exception -> Log.e(TAG, "Couldn't create file.", exception)); } return Tasks.call(mExecutor, () -> mDriveService.files() .list() .setQ( "mimeType = '" + FOLDER_MIME_TYPE + "' and trashed=false and parents = '" + subFolderId + "' ") .setSpaces("drive") .execute()); } /*Get list of all the files present in the child folder by childFolderId*/ public Task<FileList> queryChildFolderFiles(String folderId) { return Tasks.call(mExecutor, () -> mDriveService.files() .list() // I am using Sheet mime type to query the files because it was uploaded that way  .setQ( "mimeType = '" + SHEET_MIME_TYPE + "' and trashed=false and parents = '" + folderId + "' ") .setSpaces("drive") .execute()); } 

Total Answers 0