Google Drive Implementation to Android app and Downloading the file from Google drive

后端 未结 1 714
梦如初夏
梦如初夏 2021-01-12 04:40

Drive Quick-start App example works for only uploading files from Android Device to user account. I want to download the files from Gdrive to android app. any help will be

1条回答
  •  有刺的猬
    2021-01-12 05:01

    There are two steps to download file contents from Drive. First, retrieve the file's metadata and a downloadUrl for the file:

    // retrieve metadata
    File file = drive.files().get(fileId).execute();
    

    And, make an authenticated request to the downloadUrl:

    // download contents a
    GenericUrl url = new GenericUrl(file.getDownloadUrl());
    HttpResponse response = drive.getRequestFactory().buildGetRequest(url).execute();
    String contents = new Scanner(response.getContent()).useDelimiter("\\A").next();
    

    0 讨论(0)
提交回复
热议问题