QNUploadManager *upManager = [[QNUploadManager alloc] init]; QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:@"image/gif" progressHandler:nil params:@{ } checkCrc:YES cancellationSignal:nil]; NSString *imgString = [Base64Helper image2String:img]; NSData *data; data = [NSData dataWithBase64EncodedString:imgString]; [upManager putData:data key:@"bbb" token:token complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { NSLog(@"%@", info); NSLog(@"%@", resp); } option:opt]; 上面是代码,上传完的图片都默认是jpeg格式的。请问下我想上传gif格式的图片需要什么样的设置吗?
这个问题我解决了。但是没有得到社区的回答还是有点失望。不知道是不是我说的问题不够清晰。下面是解决的代码:
-(void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info
{
UIImage *img = info[UIImagePickerControllerEditedImage];//original、edited [self UpdateHeaderFileByQiNiu:info[UIImagePickerControllerReferenceURL]];
} 这是入口。
下面是处理函数UpdateHeaderFileByQiNiu
QNUploadManager *upManager = [[QNUploadManager alloc] init];
QNUploadOption *opt = [[QNUploadOption alloc] initWithMime:@"image/gif" progressHandler:nil params:@{ } checkCrc:YES cancellationSignal:nil]; ALAssetsLibrary* assetLibrary = [[ALAssetsLibrary alloc] init]; void (^ALAssetsLibraryAssetForURLResultBlock)(ALAsset *) = ^(ALAsset *asset) { if (asset != nil) { ALAssetRepresentation *rep = [asset defaultRepresentation]; Byte *imageBuffer = (Byte*)malloc(rep.size); NSUInteger bufferSize = [rep getBytes:imageBuffer fromOffset:0.0 length:rep.size error:nil]; NSData *imageData = [NSData dataWithBytesNoCopy:imageBuffer length:bufferSize freeWhenDone:YES]; [upManager putData:imageData key:@"ddd" token:token complete: ^(QNResponseInfo *info, NSString *key, NSDictionary *resp) { NSLog(@"%@", info); NSLog(@"%@", resp); } option:opt]; } else { } }; [assetLibrary assetForURL:imgUrl resultBlock:ALAssetsLibraryAssetForURLResultBlock failureBlock:^(NSError *error){ }];
遇到同样的问题了,需要大神指导。
把问题顶上去让大神们看一看吧。不要踩我。