5

I would like to upload a file using Google Drive API. I have looked at Google Drive API for Java and Google Drive API Javadoc, but I don't see anything.

5
  • I think this is what you're looking for? Commented Aug 27, 2016 at 15:35
  • @Polyov that is not using Java API Commented Aug 27, 2016 at 16:40
  • If you scroll down to here you'll see that they have examples for multiple languages, including Java. The first part just deals with the technical aspects of the REST api. Commented Aug 27, 2016 at 17:10
  • Possible duplicate of upload file into google drive using java api Commented Aug 27, 2016 at 18:43
  • Have you resolved this? Commented Sep 13, 2016 at 5:39

1 Answer 1

4

The Uploading Files in Drive API that @Polyov gave you contains a Java code snippet:

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());

Whichever language you use, the concepts remain the same like there will always be the 3 types of uploading, namely: simple upload, multipart and resumable.

There's a Java Quickstart to get you started.

If you're looking for more code samples check this github repo for your reference.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't think this is multipath upload.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.