UIActivityViewController thinks my jpg is video when share by file URL
Asked Answered
O

1

28

I have jpg files saved in the Documents directory that can be shared from a standard UIActivityViewController. All activity items (including Save Image) work as expected, but when Save Image is tapped, the following error shows in the console, despite the fact that the jpg does actually get saved to the camera roll.

Is this a bug in iOS, or do I have to somehow specify that my file is a jpg (and not a video) in the file URL?

2015-07-29 06:46:58.317 AppName[4658:893408] Video /var/mobile/Containers/Data/Application/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg cannot be saved to the saved photos album: Error Domain=AVFoundationErrorDomain Code=-11828 "Cannot Open" UserInfo=0x1702e8b80 {NSLocalizedFailureReason=This media format is not supported., NSLocalizedDescription=Cannot Open, NSURL=file:///var/mobile/Containers/Data/Application/A63DF08E-21D0-435D-A0D7-84D73D632FC9/Documents/ImageStore/805/23.jpg, NSUnderlyingError=0x170c4f9f0 "The operation couldn’t be completed. (OSStatus error -12847.)"}

Here's the code I'm using:

NSURL *fileURL = [NSURL fileURLWithPath: [...path to my file...] isDirectory:NO];
UIActivityViewController *activityViewController = [[UIActivityViewController    alloc] initWithActivityItems:@[fileURL] applicationActivities:nil];
activityViewController.excludedActivityTypes = @[UIActivityTypeCopyToPasteboard, UIActivityTypePrint, UIActivityTypeAssignToContact, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo];
[self presentViewController:activityViewController animated:YES completion:nil];
Organicism answered 29/7, 2015 at 16:10 Comment(10)
Are you sure you want to share NSURL instead of a UIImage (in @[fileURL]) ?Rosenkrantz
We started out sharing UIImage, and that worked, but the downside is there's no control over the file name that gets sent out. Sharing NSURL respects the real file name of the jpg. The strange thing is it all works, so I'm not sure why this error is even coming up.Organicism
Hi Paul, I'm experiencing this error as well. Did you ever come up with a solution? ThanksNoreen
I never did find a solution. It all works so I just had to ignore it.Organicism
Side note: if you share the image instead of the URL, you also lose properties/metadata of the image, like EXIF data etc.Sophister
I see the same error when sharing a PNG.Typography
Identical question on Apple Developer Forums: forums.developer.apple.com/thread/12700Typography
I don't think that's an issue with what you are doing. I'd suggest filing a radar (bugreporter.apple.com) to make Apple aware of this issue (the dev forums are not necessarily monitored, and as long as nobody creates a radar, this issue basically doesn't exist for Apple).Imperil
same problem, any solution?Goldy
same problem, any solution?Tadeo
K
0

I got the above message when trying to save a png file. Also noticed some other error messages. In tracking those down, got rid of both problems by applying the OS_ACTIVITY_MODE with disable as seen in following question/answer: "Reading from public effective user settings" in iOS 10

Karen answered 20/11, 2018 at 16:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.