1.保存图片到七牛中,但是如果选择的图片是100kb,保存到七牛后 空间会变为2M。由于图片变大,下载缓慢,且使用时内存大
2.保存到七牛的代码
// 图片转换为data
NSData *imageData = UIImagePNGRepresentation(weakself.coverImage);
if (imageData == nil) {
imageData = UIImageJPEGRepresentation((UIImage *)weakself.coverImage, 1.0);
}
//将图片data保存到本地
NSString *fileName = [NSString stringWithFormat:@"%@_%@", [[NSProcessInfo processInfo] globallyUniqueString], @"image.png"];
NSURL *fileUrl = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:fileName]];
NSError *error = nil;
[file writeToURL:fileUrl options:NSDataWritingAtomic error:&error];
tempFile.path 为选择图片保存到本地后的地址
keyup 为文件名
g_token 为上传的token
[_upManager putFile:tempFile.path key:keyUp token:g_token complete: ^(QNResponseInfo *i, NSString *k, NSDictionary *resp) {
key = k;
info = i;
} option:opt];
3.尝试将直接putdata到七牛,不将data保存到本地 但是效果依旧。。。
给我你的怀抱2017-05-02 09:21:47
Are you using Qiniu’s sdk? Or did you write it yourself? The size of the file uploaded by Qiniu SDK will not change. Can you provide more detailed information? Can you provide the uploaded reqestid?