简体   繁体   English

如何从Android中的Google驱动器下载mp3文件

[英]How to Download mp3 file from google drive in android

I am working on Android application in which i have to download audio files from google drive and then save these files in sd-card.. Is there any api or sample project that helps me in downloading mp3 files from google drive 我正在使用Android应用程序,在该应用程序中我必须从Google驱动器下载音频文件,然后将这些文件保存在SD卡中。是否有任何api或示例项目可以帮助我从Google驱动器下载mp3文件

OR Is there any other way to to download mp3 file from google drive programatically... 或者是否有其他方法可以通过编程方式从Google驱动器下载mp3文件...

Can we use public downloadable url for achieving above mentioned purpose 我们可以使用公共可下载网址来实现上述目的吗

Thanks 谢谢

There are two a APIs that that allow you to do it. 有两个API可以帮助您做到这一点。 The GDAA and the REST . GDAAREST None of them deals with the mp3 files specifically, though. 不过,它们都没有专门处理mp3文件。 The APIs deal with a binary file content only. 这些API仅处理二进制文件内容。 That means you: 这意味着您:

  1. Find the file first. 首先找到文件。 Either you know the name, mime type,... or you know it's Id. 您可能知道名称,mime类型...,或者您知道它是Id。 If you use REST, the Id can be extracted from the file's URL. 如果使用REST,则可以从文件的URL中提取ID。
  2. Download the content as a binary stream. 将内容下载为二进制流。
  3. Save the content as an mp3 file on Android. 在Android上将内容另存为mp3文件。

If you insist on applying the URL based Id, it is easier to use the REST, since: 如果您坚持应用基于URL的ID,则使用REST更容易,因为:

  • the URL directly corresponds with the REST Id (aka ResourceId in GDAA) 该网址直接与REST ID(即GDAA中的ResourceId)相对应
  • you can use the REST playground (bottom) to test things interactively 您可以使用REST操场 (底部)以交互方式测试事物

Also, you may use the demo code here to see the (dis)advantages of using one API or another. 另外,您可以在此处使用演示代码来查看使用一个或另一个API的(缺点)优势。 It deals with jpg content instead of mp3, but it has all the building blocks you need. 它处理的是jpg内容而不是mp3,但是它具有您需要的所有构造块。 Be sure you understand the relation of DriveId and ResourceId. 确保您了解DriveId和ResourceId的关系

Good Luck 祝好运

Go to Developers Google Website click here 转到开发者Google网站,点击此处

you will get information how to download file. 您将获得有关如何下载文件的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM