I want to send a photo from the camera roll to a web services – including its exif data.
Im using ASIFormDataRequest – so 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 the local path of the asset.
I think I can not get the local path of an asset, so I temporarily save the asset to 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 later I use this path to do the
[request addFile:localPath forKey:@"image"];
the image gets sent to the server – but without the exif data I need.
Besides that, I think there must be a smarter way to do that.
tia
ok – i think i figured it out. The trick is to go with the defaultRepresentaion’s raw data:
After using the path to send the image to the server the file on the server keeps all the exif data