UpYun *uy = [[UpYun alloc] init];
uy.successBlocker = ^(id data)
{
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"" message:@"上传成功" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
NSLog(@"%@",data);
};
uy.failBlocker = ^(NSError * error)
{
NSString *message = [error.userInfo objectForKey:@"message"];
UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"error" message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];
[alert show];
NSLog(@"%@",error);
};
uy.progressBlocker = ^(CGFloat percent, long long requestDidSendBytes)
{
[_pv setProgress:percent];
};
/**
* @brief 根据 UIImage 上传
*/
UIImage * image = [UIImage imageNamed:@"image.jpg"];
[uy uploadFile:image saveKey:[self getSaveKey]];
如上:)
可以参考这个
https://github.com/caydyn-skd/UPYUN-Swift