gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 03:03:10 27 4
gpt4 key购买 nike

我目前可以使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com