Skip to content

Instantly share code, notes, and snippets.

@zengyun-hacker
Created February 7, 2015 09:40
Show Gist options
  • Save zengyun-hacker/7336bddb8a18937f80ba to your computer and use it in GitHub Desktop.
Save zengyun-hacker/7336bddb8a18937f80ba to your computer and use it in GitHub Desktop.
how to get file name when saving a image
UIImage *image; //The image would be save
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)image.imageOrientation completionBlock:^(NSURL *assetURL, NSError *error) {
if (!error) {
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *defaultRep = [asset defaultRepresentation];
NSString *fileName = [defaultRep filename];
} failureBlock:^(NSError *error) {
}];
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment