我正在尝试将 PHLivePhoto 的 .mov 部分上传到 Facebook,但在使用 Facebook SDK 上传时出现错误:
第一次我获取 PHLivePhoto 对象并获取 .mov 的 NSData 值:
func getLivePhotoData(livePhoto:PHLivePhoto) {
let assetResources = PHAssetResource.assetResources(for: livePhoto)
for assetRes in assetResources {
if assetRes.type == .pairedVideo {
PHAssetResourceManager.default().requestData(for: assetRes, options: nil, dataReceivedHandler: { (data) in
self.uploadLivePhoto(data)
}, completionHandler: { (error) in
print(error)
})
}
}
}
然后我尝试按如下方式上传 NSData 对象:
func uploadLivePhoto(livePhotoData:Data) {
var parameters = [AnyHashable: Any]()
parameters["video.mov"] = data
parameters["access_token"] = MY_ACCESS_TOKEN
FBSDKGraphRequest(graphPath: "/FACEBOOK_PAGE_NAME/videos", parameters: parameters, httpMethod: "POST").start(completionHandler: { (FBSDKGraphRequestConnection, result, error) -> Void in
print(result)
print(error)
})
}
我收到以下错误:
body = {
error = {
code = 6000;
"error_subcode" = 1363032;
"error_user_msg" = "It looks like you're trying to upload something that isn't a video or that's corrupt. Please upload a video in a supported format.";
"error_user_title" = "No Video Detected";
"fbtrace_id" = DlziJW0f7BN;
"is_transient" = 0;
message = "There was a problem uploading your video file. Please try again with another file.";
type = OAuthException;
};
};