将资产视频发送到网络服务 - iOS
Send Asset Video to web service - iOS
我正在尝试使用参数 video
将资产库中的视频发送到 Web 服务,但是这怎么可能呢?
我得到 NSURL
如下:assets-library://asset/asset.MOV?id=What-ever-0000-000&ext=MOV
我正在使用 AFNetworking
发送 post 请求,这是我的代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]];
[manager.requestSerializer setValue:@"no-cache" forHTTPHeaderField:@"Catch-Control"];
NSDictionary *parameters = @{@"video": myurl};
[manager POST:@"this is my service link" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
我是否需要将 NSURL
转换为另一种表示形式才能提交?我不知道?
您可以像这样post将视频上传到服务器。
AFHTTPRequestOperation *op = [theManager POST:urlString
parameters:theParameters
constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
[formData appendPartWithFileURL:postedVideoURL name:@"media" fileName:@"FinalMovie.mp4" mimeType:@"mp4" error:nil];
[formData appendPartWithFileData:imgData name:@"video_thumb" fileName:@"png" mimeType:@"image/jpeg"];
}
success:^(AFHTTPRequestOperation *operation, id responseObject)
{}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{}];
[op start];
像这样创建 theManager 对象。
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
希望对您有所帮助。
我正在尝试使用参数 video
将资产库中的视频发送到 Web 服务,但是这怎么可能呢?
我得到 NSURL
如下:assets-library://asset/asset.MOV?id=What-ever-0000-000&ext=MOV
我正在使用 AFNetworking
发送 post 请求,这是我的代码:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager setSecurityPolicy:[AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone]];
[manager.requestSerializer setValue:@"no-cache" forHTTPHeaderField:@"Catch-Control"];
NSDictionary *parameters = @{@"video": myurl};
[manager POST:@"this is my service link" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
我是否需要将 NSURL
转换为另一种表示形式才能提交?我不知道?
您可以像这样post将视频上传到服务器。
AFHTTPRequestOperation *op = [theManager POST:urlString
parameters:theParameters
constructingBodyWithBlock:^(id<AFMultipartFormData> formData)
{
[formData appendPartWithFileURL:postedVideoURL name:@"media" fileName:@"FinalMovie.mp4" mimeType:@"mp4" error:nil];
[formData appendPartWithFileData:imgData name:@"video_thumb" fileName:@"png" mimeType:@"image/jpeg"];
}
success:^(AFHTTPRequestOperation *operation, id responseObject)
{}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{}];
[op start];
像这样创建 theManager 对象。
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
希望对您有所帮助。