I want to send a photo from a camera roll to web services, including exif data. Im using ASIFormDataRequest - so what I do:
ASIFormDataRequest *request = [[ASIFormDataRequest alloc]initWithURL:url];
To save memory, I directly want to send the file:
[request addFile:localPath forKey:@"image"];
So, I need a local path to the resource. I think I canβt get the local path to the resource, so I temporarily save it in a file:
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];
Then I use this path to execute
[request addFile:localPath forKey:@"image"];
the image is sent to the server, but without the exif data that I need. Also, I think there should be a smarter way to do this.
TIA
source share