error = {java.lang.String@4266}"file or data size is zero"
每次上传都给我返回这个怎么弄 ,token, key, filepath我都传了(上传到七牛服务器)
我猜测几种可能,七牛服务器出现问题了。图片格式不对或者图片没有按照指定要求,比如太大。如果是java代码和数据库交互,那么可能是数据库字段是否对应。
具体什么问题我也没遇到过。
我估计图片太大的概率比较高
key要传空值,如果图片太大要适当压缩
QNUploadManager *upManager = [[QNUploadManager alloc] init];
for (UIImage*image in self.tmpImageArray) {
NSData *data = UIImageJPEGRepresentation(image,1);
CGFloat bit = data.length;
if (bit/1024.0>5){
data = UIImageJPEGRepresentation(image,0.4);
}
QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:nil progressHandler:^(NSString *key, float percent) {
} params:nil checkCrc:YES cancellationSignal:nil];
[upManager putData:data key:nil token:token
complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) {
//isOK
imageCount++;
if (resp) {
[imageArray addObject:[resp objectForKey:@"key"]];
}
if (imageArray.count == self.tmpImageArray.count) {
NSString*imageString = [imageArray componentsJoinedByString:@","];
[self upLoadImageFromImageString:imageString withArray:imageArray withCount:0];
}
else {
if (imageCount == self.tmpImageArray.count) {
NSString *errorstring = @"上传失败,Qiniu key获取失败";
if (info) {
errorstring = [NSString stringWithFormat:@"上传失败,error:%ld",(long)info.error.code];
}
[[AppDelegate appDelegate] appDontCoverLoadingViewShowForContext:errorstring ForTypeShow:1 ForChangeFrameSizeType:0 ForFrameFlg:YES ForCancelTime:2.0];
}
}
} option:opt
];
}iOS的是这样写的,应该有相通之处
请问有 没有解决,我也遇到了相同的问题,只能延迟四五秒钟才能返回成功