I am uploading files to Drive using rest api(Version 3), I am able to upload those. But when I try to export that file then I am getting
403:Export only supports Google Docs.
If I create file on drive editor and then export that, it gets exported properly. In Version 2 of API I could see there was an option
convert=true
But in Version 3 there is no such option.
Stack over Flow link But this is for Version 2
When uploading files, you just have to specify the Google docs mimeType for them to be a Drive file.
The documentation gave an example of converting a .csv file in to a Sheets file.
File fileMetadata = new File();
fileMetadata.setName("My Report");
fileMetadata.setMimeType("application/vnd.google-apps.spreadsheet");
java.io.File filePath = new java.io.File("files/report.csv");
FileContent mediaContent = new FileContent("text/csv", filePath);
File file = driveService.files().create(fileMetadata, mediaContent)
.setFields("id")
.execute();
System.out.println("File ID: " + file.getId());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With