2016-06-20 3 views
0

Google 드라이브에서 휴대 전화로 파일을 다운로드하고 싶습니다. 지금까지 앱에서 Google 드라이브에 액세스 할 수 있지만 Google 드라이브에서 파일을 선택할 수는 있지만 다운로드 할 수는 없습니다. 휴대 전화의 Google 드라이브 앱에서 할 수 있지만 내 앱에서 해당 작업이 필요합니다. 난 내 응용 프로그램을 통해 Google 드라이브에 접근하고있어이 코드Google 드라이브에서 휴대 전화로 파일을 다운로드하려면 어떻게해야하나요?

public void openFolder() { 

    Intent intent = new Intent(Intent.ACTION_GET_CONTENT); 
    Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath() 
      + "/Android/data/com.google.android.apps.docs/files/"); 
    intent.setDataAndType(uri, "text/mp3"); 
    startActivity(Intent.createChooser(intent, "Open folder")); 

} 

. 도움이 필요하십니까? 미리 감사드립니다.

답변

0

구글의 지침 말 :

파일을 다운로드하려면, 당신이 파일의 리소스 URL에 인증 된 HTTP GET 요청을하고 쿼리 매개 변수 고도 = 매체를 포함한다. 예를 들어 : 무기명 ya29.AHESVbXTUv5mHMo3RYfmS1YJonjzzdTOFZwvyOAUVhrs (자바)

예제 코드 :

String fileId = "0BwwA4oUTeiV1UVNwOHItT0xfa2M"; 
OutputStream outputStream = new ByteArrayOutputStream(); 
driveService.files().get(fileId) 
     .executeMediaAndDownloadTo(outputStream); 

당신은 https://developer.android.com을 확인해야

https://www.googleapis.com/drive/v3/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media 인증을 GET. 또한 Google 드라이브에서 파일을 다운로드하는 방법에 대한 구체적인 정보가있는 페이지는 다음과 같습니다. https://developers.google.com/drive/v3/web/manage-downloads#examples

관련 문제