phasset

PHAsset get original file name

╄→尐↘猪︶ㄣ 提交于 2019-12-02 18:19:23
I wonder if there any way to get the original file name using PHAsset? I use the following code to extract the file info. [[PHImageManager defaultManager] requestImageDataForAsset:asset options:requestOption resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { entity.fileUrl = [info objectForKey:@"PHImageFileURLKey"]; entity.filename = [[NSFileManager defaultManager] displayNameAtPath:[ entity.fileUrl path]]; }]; However, It doesn't return original name but the name in the format "img_123" I've just checked official apple docs . there has

How to get photo from My Photo Stream Album

被刻印的时光 ゝ 提交于 2019-12-02 11:49:16
I want to get Photo from My Photo Stream. I have only localIdentifier of PHAsset. For photos other than My Photo Stream album I am using below code for retrieve PHAsset. [PHAsset fetchAssetsWithLocalIdentifiers:@[“localIdentifier”] options:nil].firstObject localIdentifier is like ' 1BFC3BA2-AC95-403A-B4FF-B26AFB631581/L0/001 ' it's working fine. But in my My Photo Stream album I am getting nil value of PHAsset. Does anyone having a idea how we can get original Photo from My Photo Stream using localIdentifier value of PHAsset? I got an answer myself. I retrieve all photostream photos and

How to get Original Image and media type from PHAsset?

只愿长相守 提交于 2019-12-01 09:17:09
My **GMImagePickerController** returns the list of selected images from photos app. The code are as follows. - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickingAssets:(NSArray *)assetArray { NSLog(@"%@",assetArray); NSLog(@"GMImagePicker: User ended picking assets. Number of selected items is: %lu", (unsigned long)assetArray.count); } The assetArray return result like this, I selected 3 images from photos app ( "<PHAsset: 0x7fa39e02e840> 1AEEF04A-F8AB-4019-AAB5- 2875CFD8F8E3/L0/001 mediaType=1/0, sourceType=1, (425x425), creationDate=2016-02-03 13:53:17 +0000,

How to get NSData from file by using PHAsset

馋奶兔 提交于 2019-12-01 08:37:01
I have file at path file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov But when I try this code- NSError *error; NSData *data = [NSData dataWithContentsOfFile:assetUrl.relativePath options:NSDataReadingMappedAlways error:&error]; I got nothing but error: Error Domain=NSCocoaErrorDomain Code=257 "Не удалось завершить операцию. (Cocoa, ошибка 257)" UserInfo=0x175a61380 {NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0197.mov, NSUnderlyingError=0x17424e550 "Не удалось завершить операцию. Operation not permitted"} File exists but I can't read it. But at the same time AVPlayer normally plays video

How to get NSData from file by using PHAsset

两盒软妹~` 提交于 2019-12-01 06:44:29
问题 I have file at path file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov But when I try this code- NSError *error; NSData *data = [NSData dataWithContentsOfFile:assetUrl.relativePath options:NSDataReadingMappedAlways error:&error]; I got nothing but error: Error Domain=NSCocoaErrorDomain Code=257 "Не удалось завершить операцию. (Cocoa, ошибка 257)" UserInfo=0x175a61380 {NSFilePath=/var/mobile/Media/DCIM/100APPLE/IMG_0197.mov, NSUnderlyingError=0x17424e550 "Не удалось завершить операцию.

PHAsset + AFNetworking. Unable to upload files to the server on a real device

与世无争的帅哥 提交于 2019-11-30 10:51:43
Currently I'm using the following code to upload files to the server NSURLRequest *urlRequest = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[[entity uploadUrl]absoluteString] parameters:entity.params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { // Get file url [UploadModel getAassetUrl:entity.asset resultHandler:^(NSURL *fileUrl) { NSError *fileappenderror; // Append [formData appendPartWithFileURL:fileUrl name:@"data" error:&fileappenderror]; if (fileappenderror) { [Sys MyLog: [fileappenderror localizedDescription] ]; } }]; } error

How to identify if a PHAsset is not completely downloaded from iCloud (so I need to request again with options.networkAccessAllowed)

冷暖自知 提交于 2019-11-30 10:30:07
问题 The docs say: PHImageResultIsInCloudKey: A Boolean value indicating whether the photo asset data is stored on the local device or must be downloaded from iCloud. (NSNumber) If YES, no image was provided, because the asset data must be downloaded from iCloud. To download the data, submit another request, and specify YES for the networkAccessAllowed option. But this key is always YES when a asset is stored in the iCloud Photo Library, even when it is already completely downloaded to the device

Connection to assetsd was interrupted or assetsd died

我与影子孤独终老i 提交于 2019-11-30 04:01:55
I load photos from PHAssets. I get this error log when I load some images and pass them to another view controller. I can't seem to find anything online about this. Anyone encounter this and know what it is? I also get this error along with it: ***** Error: logging directory does not exist /var/mobile/Library/Logs/CrashReporter/DiagnosticLogs/ Shobhakar Tiwari There may be following reason : 1.) It may occur when we try to use multiple Image view (Image) so just image and try to release it , it will solve problem. 2.) Also to avoid create too many property for storing images . 3.) If we need

How to identify if a PHAsset is not completely downloaded from iCloud (so I need to request again with options.networkAccessAllowed)

萝らか妹 提交于 2019-11-29 20:44:23
The docs say: PHImageResultIsInCloudKey: A Boolean value indicating whether the photo asset data is stored on the local device or must be downloaded from iCloud. (NSNumber) If YES, no image was provided, because the asset data must be downloaded from iCloud. To download the data, submit another request, and specify YES for the networkAccessAllowed option. But this key is always YES when a asset is stored in the iCloud Photo Library, even when it is already completely downloaded to the device (downloaded it in my app, also opened it in the Photos app). If an image is not available I want to

Save image to photo library using photo framework

亡梦爱人 提交于 2019-11-29 01:57:56
My app crashes every time when I try to save image using photo framework. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ _mChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info valueForKey:UIImagePickerControllerOriginalImage]]; [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ _mChangeRequest = [PHAssetChangeRequest creationRequestForAssetFromImage:[info valueForKey:UIImagePickerControllerOriginalImage]]; } completionHandler:^(BOOL success, NSError *error) { if (success) { PHObjectPlaceholder