如何使用 CORS 或 API 的凭据与 javascript 共享来自 Google 驱动器的 mp3 文件
How to share mp3 files from Google Drive with javascript with credentials for CORS or API
我在 Google 驱动器中存储了不同的 mp3 文件,我用 javascript 播放它们。首先我使用了以下代码:
var audio1 = new Audio("https://docs.google.com/uc?export=open&id='id'");
但后来我突然收到 cors policy no 'access-control-allow-origin' 的警告消息,突然音频文件不再工作并出现 get 403 错误。然后我使用 Google API 和以下代码:
var audio1 = new Audio("https://www.googleapis.com/drive/v3/files/'id'?alt=media&key='key'&v=.mp3");
有人这样也行不通。音频突然停止播放。我收到有关文件的 get 403 错误。有时我什至会收到太多请求的消息。我在某处读到我应该将凭据放在 http header 中。但是,在我正在使用的原型程序中无法访问 http header。
有人知道如何重复播放不同的 mp3 文件而不会遇到任何凭据问题吗?
The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Google Drive, and create robust functionality in your application using Google Drive API.
Google 驱动器 API 不适合用作文件服务器。它只是一个文件存储系统。你试图做的是行不通的。
您应该考虑将文件存储在您自己的文件服务器上。如果您要在 Google 云服务器上查找内容,您还可以查看 Google cloud storage。
我在 Google 驱动器中存储了不同的 mp3 文件,我用 javascript 播放它们。首先我使用了以下代码:
var audio1 = new Audio("https://docs.google.com/uc?export=open&id='id'");
但后来我突然收到 cors policy no 'access-control-allow-origin' 的警告消息,突然音频文件不再工作并出现 get 403 错误。然后我使用 Google API 和以下代码:
var audio1 = new Audio("https://www.googleapis.com/drive/v3/files/'id'?alt=media&key='key'&v=.mp3");
有人这样也行不通。音频突然停止播放。我收到有关文件的 get 403 错误。有时我什至会收到太多请求的消息。我在某处读到我应该将凭据放在 http header 中。但是,在我正在使用的原型程序中无法访问 http header。
有人知道如何重复播放不同的 mp3 文件而不会遇到任何凭据问题吗?
The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Google Drive, and create robust functionality in your application using Google Drive API.
Google 驱动器 API 不适合用作文件服务器。它只是一个文件存储系统。你试图做的是行不通的。
您应该考虑将文件存储在您自己的文件服务器上。如果您要在 Google 云服务器上查找内容,您还可以查看 Google cloud storage。