Ios 如何下载音频文件?
我想用谷歌硬盘API下载音频文件(mp3、m4a、wma…)。尝试下面的代码,我得到了模拟器上的错误 错误:Ios 如何下载音频文件?,ios,google-drive-api,swift3,Ios,Google Drive Api,Swift3,我想用谷歌硬盘API下载音频文件(mp3、m4a、wma…)。尝试下面的代码,我得到了模拟器上的错误 错误: The operation could't be completed. (The user has not granted the app xxxx read access to the file alEnlflseiFNSEi.) let url = "https://www.googleapis.com/drive/v3/files/\(identifier)?alt=media"
The operation could't be completed. (The user has not granted the app xxxx read access to the file alEnlflseiFNSEi.)
let url = "https://www.googleapis.com/drive/v3/files/\(identifier)?alt=media"
service.fetchObject(
with: URL(string: url)!,
delegate: self,
didFinish: #selector(GoogleDriveFileListTableViewController.downloadWithTicket(ticket:finishedWithObject:error:))
)
代码:
The operation could't be completed. (The user has not granted the app xxxx read access to the file alEnlflseiFNSEi.)
let url = "https://www.googleapis.com/drive/v3/files/\(identifier)?alt=media"
service.fetchObject(
with: URL(string: url)!,
delegate: self,
didFinish: #selector(GoogleDriveFileListTableViewController.downloadWithTicket(ticket:finishedWithObject:error:))
)
关于您的“读取访问”问题,以下是: 下载文件要求用户至少具有读取权限。 此外,您的应用程序必须在允许的范围内获得授权 读取文件内容。例如,使用 drive.readonly.metadata作用域将无权下载 文件内容。具有编辑权限的用户可以通过以下方式限制下载: 通过将viewersCanCopyContent字段设置为true来创建只读用户 尝试使用获取音频文件的WebContent链接。单击或在新窗口中打开此链接时,将下载音频文件 它看起来像这样:
https://drive.google.com/uc?id=0Bzgk4zccNwI7TzBxZTFzbHFhdUU&export=download
谢谢我得到了它。我发现了一个错误。不需要?alt=URL中的媒体。我检查来自web的响应。