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];
Pang
  • 9,564
  • 146
  • 81
  • 122
Paul B.
  • 458
  • 3
  • 6
  • Are you sure you want to share `NSURL` instead of a `UIImage` (in `@[fileURL]`) ? – Larme Jul 29 '15 at 16:30
  • 4
    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. – Paul B. Jul 29 '15 at 19:52
  • Hi Paul, I'm experiencing this error as well. Did you ever come up with a solution? Thanks – Jason Jan 04 '16 at 14:33
  • I never did find a solution. It all works so I just had to ignore it. – Paul B. Jan 04 '16 at 17:41
  • Side note: if you share the image instead of the URL, you also lose properties/metadata of the image, like EXIF data etc. – Lepidopteron Feb 03 '17 at 07:29
  • 1
    I see the same error when sharing a PNG. – Pang Jul 31 '17 at 08:05
  • Identical question on Apple Developer Forums: https://forums.developer.apple.com/thread/12700 – Pang Jul 31 '17 at 08:08
  • I don't think that's an issue with what you are doing. I'd suggest filing a radar (http://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). – Michael Ochs Jul 31 '17 at 08:10
  • 2
    same problem, any solution? – Nininea Dec 06 '17 at 09:55
  • same problem, any solution? – Hassan Taleb Jul 05 '22 at 08:55

1 Answers1

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

anorskdev
  • 1,867
  • 1
  • 15
  • 18