Skip to content

hlcfan/QiniuUploader

Repository files navigation

QiniuUploader

QiniuUploader for iOS with AFNetworking 2.0 - single image or multi images supported

Prepare

install AFNetworking 2.0

pod "AFNetworking", "~> 2.0"

Usage:

  1. Import header file #import "QiniuUploader.h"

  2. Prepare fileInfo before upload.

NSDictionary *avatarHash = [QiniuUploader prepareUploadContent: self.avatarInfo filename: @"avatar" format: @"jpg" bucket: QiniuAvatarBucketName imageCompress: nil];
NSDictionary *avatar2Hash = ...
NSMutableArray *uploadArray = [NSMutalbeArray arrayWithObjects: avatarHash, ..., nil];
  1. Upload!
QiniuUploader *uploader = [[QiniuUploader alloc] initWithAccessKey: QiniuAccessKey secretKey: QiniuSecretKey];
  [uploader startUploadFiles:uploadArray progress:^(float percentage) {
    NSLog(@"===Percent:%f", percentage);
  } complete:^(NSMutableDictionary *result) {
      if([[result objectForKey:@"success"] boolValue]){
        NSLog(@"===upload success");
      }else{
        NSLog(@"===upload fail");
      }
  }];

Compress upload image

NSDictionary *avatar2Hash = [QiniuUploader prepareUploadContent:self.bannerInfo filename:@"avatar" format:@"jpg" bucket: QiniuAvatarBucketName imageCompress:^UIImage *(UIImage *image) {
    CGSize newSize = CGSizeMake(100.0f, 100.0f);
    UIGraphicsBeginImageContext(newSize);
    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}];

About

QiniuUploader for iOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published