我想将照片从相机胶卷发送到网络服务 - 包括其 exif 数据。我使用 ASIFormDataRequest - 所以我这样做:
ASIFormDataRequest *request = [[ASIFormDataRequest alloc]initWithURL:url];
为了节省内存,我直接想发送文件:
[request addFile:localPath forKey:@"image"];
所以我需要资产的本地路径。我想我无法获取资产的本地路径,所以我暂时将资产保存到文件中:
ALAsset* selectedAsset = [assets objectAtIndex:index];
CGImageRef imageRef = selectedAsset.defaultRepresentation.fullScreenImage;
UIImage* image = [UIImage imageWithCGImage:imageRef];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDirectory = [paths objectAtIndex:0];
NSData* imageData = UIImagePNGRepresentation(image);
NSString* filePath = [NSString stringWithFormat:@"%@/imageTemp.png",cachesDirectory];
[imageData writeToFile:filePath atomically:YES];
然后稍后我使用这条路径来做
[request addFile:localPath forKey:@"image"];
图像被发送到服务器 - 但没有我需要的 exif 数据。除此之外,我认为必须有更聪明的方法来做到这一点。
蒂亚