ios - 将带有 MP3 文件的 ID3 标签上传到 Google Drive - iOS SDK

标签 ios google-drive-api

我目前可以使用 iOS SDK 将 MP3 文件上传到 Google Drive,但是我遇到了无法在文件中组合 ID3 标签的问题。有没有办法将此信息直接添加到 GTLDriveFile 中,或者至少有一些替代方法?

当前代码:

GTLDriveParentReference *parentRef = [GTLDriveParentReference object];
parentRef.identifier = self.kDriveMusicDirID;
parentRef.isRoot = NO;

GTLDriveFileThumbnail *thumbnail = [[GTLDriveFileThumbnail alloc] init];
thumbnail.image = GTLEncodeWebSafeBase64(UIImageJPEGRepresentation(file.image, 80));
thumbnail.mimeType = @"image/jpeg";

GTLDriveFile *driveFile = [[GTLDriveFile alloc] init];
NSString *title = [NSString stringWithFormat:@"%@ - %@.mp3", file.artist,    file.songTitle];
driveFile.title = title;
driveFile.mimeType = @"audio/mp3";
driveFile.parents = @[parentRef];
driveFile.thumbnail = thumbnail;

AVURLAsset *songAsset = [AVURLAsset assetWithURL:file.assetURL];
[self extractDataForAsset:songAsset withCallback:^(NSData *data, NSError *error)
{
if (error == nil)
{
GTLUploadParameters *uploadParameters =
[GTLUploadParameters uploadParametersWithData:data
                                     MIMEType:driveFile.mimeType];

GTLQueryDrive *query = [GTLQueryDrive queryForFilesInsertWithObject:driveFile
                                                   uploadParameters:uploadParameters];

[self.driveService executeQuery:query
              completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error)
   {
   if (error == nil)
   {
     completion(nil);
   }
   else
   {
     completion(error);
   }
 }];
}
else
{
  //handle the error. notification that the upload has failed.
}
}];

最佳答案

Google Drive 允许我们以简单上传、分段上传和可恢复上传的方式上传文件。如果您有要与要上传的数据一起发送的元数据,则可以发出单个多部分/相关请求

要使用分段上传,向方法的/upload URI 发出 POST 或 PUT 请求并添加查询参数 uploadType=multipart,

例如:

发布https://www.googleapis.com/upload/drive/v2/files?uploadType=multipart

更多详情请引用HERE

关于ios - 将带有 MP3 文件的 ID3 标签上传到 Google Drive - iOS SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23080433/

相关文章:

google-drive-api - Google云端硬盘MIME类型列表?

html - 将 Google 表单集成到网站中

javascript - Google Drive API 和从浏览器上传文件

ios - Visual Studio 2017 (Windows) 不显示 Mac 上所有可用的 ios 模拟器设备

ios - Spritekit 在玩游戏时保留 iPhone 音乐

ios - 是否可以为 iBeacon 提示设置延迟时间?

android - 如何自动测试 iOS 和 Android 应用程序的功能?

ios - RESTKit:对象正在失去关系

java - Google Drive v3 java API 获取服务帐户配额

api - 检测 Google 云端硬盘更改