Phphotoserrordomain ошибка 3302

When trying to save screen recording file to my device like:

PHPhotoLibrary.shared().performChanges({() -> Void in
                    PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
                }, completionHandler: { (_, error) -> Void in
                    if let error = error {
                        self.showAlert(title: .saveFailed, message: error.localizedDescription)
                        return
                    }
                    do {
                        try FileManager.default.removeItem(at: url)
                        self.showAlert(title: .saved) {
                            self.dismissSelf()
                        }
                    } catch let error {
                        print(error)
                    }
                })

It sometime fails with error:

Domain=PHPhotosErrorDomain Code=3302

Which mean:

case invalidResource = 3302 // Asset resource validation failed

It succeed sometimes though.
Does anyone know what is the invalidResource error mean??

Looks like no one’s replied in a while. To start the conversation again, simply

ask a new question.

hi, when I want to upload photos to a shared album, I get an error ‘PHPhotosErrorDomain error 3302’, and no photo is uploaded in the shared album. Kindly assist.

Posted on Jul 14, 2022 1:47 AM

Similar questions

  • Can’t Upload Photos to Shared Album
    I have created a shared album and have tried to add photos by both the «drag and drop» method and «adding photos» from the option within the album.I get an odd error message that says «Internet Connection Required- An internet connection is required to download larger versions of these items for sharing,» and no photos end up in the album, the album remains empty.I am most certainly connected to the internet.Any thoughts?

    3742
    8

  • Shared Album not loading photos
    My shared album isn’t loading the photos, and when I click on them they are just gray squares. How do I make them load?

    644
    1

  • Can’t upload photos to shared cloud album
    Dear folks,

    All the time I try to upload photos to the shared cloud album I created, the system starts to prepare it and then it crashes.

    I’ve uploaded about 500 photos to this album already step by step, sending 20-50 photos per each upload, but now it goes down even when I try to upload 5+ photos.

    Please advise?

    Thank you.

    112
    1

4 replies

Jul 14, 2022 1:53 PM in response to baba masele

Hi

Are you able to open these images in edit mode?

Do you use iCloud photos with optimise mac storage selected?

Jul 15, 2022 5:48 AM in response to baba masele

Once you have opened an image in edit mode, are you then able to add it to the shared album?

Jul 15, 2022 6:22 AM in response to TonyCollinet

hi, if I go to Add photos in that album, I can add photos. But, if I select a person in people’s album, and chose to add that person in the shared album (named after that person), I get that error. Basically, I have created a shared album of my son called, Samuel, and I want to put all of Samuel’s photos in the shared album. It’s not working.

Uploading photos to shared album

I am processing an H264 encoded video stream from a non-apple IoT device. I want to record bits of this video stream.

I’m getting an error when I try to save to the photo gallery:

The operation couldn’t be completed. (PHPhotosErrorDomain error 3302.)

My Code, let me know if I need to share more:

  private func beginRecording() {
    self.handlePhotoLibraryAuth()
    self.createFilePath()
    guard let videoOutputURL = self.outputURL,
       let vidWriter = try? AVAssetWriter(outputURL: videoOutputURL, fileType: AVFileType.mp4),
       self.formatDesc != nil else {
         print("Warning: No Format For Video")
         return
       }
    let vidInput = AVAssetWriterInput(mediaType: AVMediaType.video, outputSettings: nil, sourceFormatHint: self.formatDesc)
    guard vidWriter.canAdd(vidInput) else {
      print("Error: Cant add video writer input")
      return
    }
     
    let sourcePixelBufferAttributes = [
      kCVPixelBufferPixelFormatTypeKey as String: NSNumber(value: kCVPixelFormatType_32ARGB),
      kCVPixelBufferWidthKey as String: "1280",
      kCVPixelBufferHeightKey as String: "720"] as [String : Any]
     
    self.videoWriterInputPixelBufferAdaptor = AVAssetWriterInputPixelBufferAdaptor(
      assetWriterInput: vidInput,
      sourcePixelBufferAttributes: sourcePixelBufferAttributes)
    vidInput.expectsMediaDataInRealTime = true
    vidWriter.add(vidInput)
    guard vidWriter.startWriting() else {
      print("Error: Cant write with vid writer")
      return
    }
    vidWriter.startSession(atSourceTime: CMTimeMake(value: self.videoFrameCounter, timescale: self.videoFPS))
    self.videoWriter = vidWriter
    self.videoWriterInput = vidInput
    print("Recording Video Stream")
  }

Save the Video

  private func saveRecordingToPhotoLibrary() {
    let fileManager = FileManager.default
    guard fileManager.fileExists(atPath: self.path) else {
      print("Error: The file: (self.path) not exists, so cannot move this file camera roll")
      return
    }
    print("The file: (self.path) has been save into documents folder, and is ready to be moved to camera roll")
    PHPhotoLibrary.shared().performChanges({
      PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: URL(fileURLWithPath: self.path))
    }) { completed, error in
      guard completed else {
        print ("Error: Cannot move the video (self.path) to camera roll, error: (String(describing: error?.localizedDescription))")
        return
      }
      print("Video (self.path) has been moved to camera roll")
    }
  }

 When Recording ends we save the video

  private func endRecording() {
    guard let vidInput = videoWriterInput, let vidWriter = videoWriter else {
      print("Error, no video writer or video input")
      return
    }
    vidInput.markAsFinished()
    if !vidInput.isReadyForMoreMediaData {
      vidWriter.finishWriting {
        print("Finished Recording")
        guard vidWriter.status == .completed else {
          print("Warning: The Video Writer status is not completed, status: (vidWriter.status.rawValue)")
          print(vidWriter.error.debugDescription)
          return
        }
        print("VideoWriter status is completed")
        self.saveRecordingToPhotoLibrary()
      }
    }
  }

I am using the code below to import images into a Photos Library.
The code works for JPGs and HEICs but when it encounters Apple ProRaw (DNG) files it give the following error messages:

Error Domain=PHPhotosErrorDomain Code=3302
findWriterForTypeAndAlternateType:119: unsupported file format 'com.adobe.raw-image'

Here is the code:

func createPhotoOnAlbum(photo: UIImage, album: PHAssetCollection) {
        

            PHPhotoLibrary.shared().performChanges({
                    // Request creating an asset from the image
                    let createAssetRequest = PHAssetChangeRequest.creationRequestForAsset(from: photo)
                    // Request editing the album
                    guard let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) else {
                        print("album change request has failed")
                        // Album change request has failed
                        return
                    }
                    // Get a placeholder for the new asset and add it to the album editing request
                    guard let photoPlaceholder = createAssetRequest.placeholderForCreatedAsset else {
                        // Photo Placeholder is nil
                        return
                    }
                    albumChangeRequest.addAssets([photoPlaceholder] as NSArray)
                }, completionHandler: { success, error in
                    if success {
                        // Saved successfully!
                        print("saved successfully")
                        self.importCount += 1
                    }
                    else if let e = error {
                        // Save photo failed with error
                        print("error saving: (error)")
                    }
                    else {
                        print("error -> ")
                        // Save photo failed with no error
                    }
                })

These are definitely unedited ProRaw DNGs.

On a Mac they can be imported into a Photos Library using the «Import» menu command.

On an iPad they can be brought into the Photos Library by selecting them in the file system on the iPad, tapping Share, then tapping Save Images.

Thank you for any assistance with this.

===============

I’ve tried a different approach and now I can add the DNG files:

func createStillAssetOnAlbum(asset: URL, album: PHAssetCollection) {
    let photoURL = asset
    PHPhotoLibrary.shared().performChanges ({

        let creationRequest = PHAssetCreationRequest.forAsset()
        let placeHolderAsset = creationRequest.placeholderForCreatedAsset

        creationRequest.addResource(with: .photo, fileURL: photoURL, options: nil)
        
        guard let albumChangeRequest = PHAssetCollectionChangeRequest(for: album) else {
            print("album change request has failed")
            return
        }
        albumChangeRequest.addAssets([placeHolderAsset] as NSArray)
        
    }, completionHandler: { success, error in
        if success {
            print("photo (and adjustments) saved successfully")
            self.importCount += 1
        }
        else if let e = error {
            print("error saving photo (and adjustment): (e)")
            self.nonImportedImageCount += 1
        }
    })
}

[Runner] findWriterForTypeAndAlternateType:119: unsupported file format 'org.webmproject.webp'
Unsupported value: Error Domain=PHPhotosErrorDomain Code=3302 "(null)" of type NSError
*** Assertion failure in -[FlutterStandardWriter writeValue:], FlutterStandardCodec.mm:338
[xpc.exceptions] <NSXPCConnection: 0x280fb8a00> connection to service with pid 233 named com.apple.photos.service: Exception caught during invocation of reply block to message 'applyChangesRequest:reply:'.
Exception: Unsupported value for standard codec
(
	0   CoreFoundation                      0x00000001d96f2254 42C5C917-0447-3995-B50F-DE4D132C2435 + 41556
	1   libobjc.A.dylib                     0x00000001d2ab7a68 objc_exception_throw + 60
	2   Foundation                          0x00000001d407681c AA92CD58-561A-3414-92F4-B4120298B39A + 5531676
	3   Flutter                             0x00000001069ec740 -[FlutterStandardMethodCodec encodeErrorEnvelope:] + 196
	4   Flutter                             0x00000001069e96e0 __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke_2 + 136
	5   image_downloader                    0x0000000103e61800 $syXlSgIeyBy_ypSgIegn_TR + 200
	6   image_downloader                    0x0000000103e6376c $s16image_downloader26SwiftImageDownloaderPluginC04saveD033_055A23EAE8999497637EB0A0A2513C79LL_6resulty10Foundation4DataV_yypSgctFySb_s5Error_pSgtcfU0_ + 944
	7   image_downloader                    0x0000000103e639dc $sSbs5Error_pSgIegyg_SbSo7NSErrorCSgIeyByy_TR + 68
	8   Photos                              0x00000001edf34140 FE7FF9BF-2EB8-38D1-A329-563EC9385296 + 229696
	9   Photos                              0x00000001edf36c5c FE7FF9BF-2EB8-38D1-A329-563EC9385296 + 240732
	10  Photos                              0x00000001ee00499c FE7FF9BF-2EB8-38D1-A329-563EC9385296 + 1083804
	11  Photos                              0x00000001edf47b94 FE7FF9BF-2EB8-38D1-A329-563EC9385296 + 310164
	12  CoreFoundation                      0x00000001d975ca14 42C5C917-0447-3995-B50F-DE4D132C2435 + 477716
	13  CoreFoundation                      0x00000001d9708f2c 42C5C917-0447-3995-B50F-DE4D132C2435 + 134956
	14  Foundation                          0x00000001d3bd0d38 AA92CD58-561A-3414-92F4-B4120298B39A + 658744
	15  Foundation                          0x00000001d3ba22fc AA92CD58-561A-3414-92F4-B4120298B39A + 467708
	16  Foundation                          0x00000001d417cf44 AA92CD58-561A-3414-92F4-B4120298B39A + 6606660
	17  libxpc.dylib                        0x00000002260713e4 BE45E2E7-648C-3A60-9C57-E63229B6CFE0 + 119780
	18  libxpc.dylib                        0x0000000226064580 BE45E2E7-648C-3A60-9C57-E63229B6CFE0 + 66944
	19  libdispatch.dylib                   0x00000001e0b6e05c C663D847-B94F-3FB0-9254-32EDBC55315E + 16476
	20  libdispatch.dylib                   0x00000001e0b8bf58 C663D847-B94F-3FB0-9254-32EDBC55315E + 139096
	21  libdispatch.dylib                   0x00000001e0b7556c C663D847-B94F-3FB0-9254-32EDBC55315E + 46444
	22  libdispatch.dylib                   0x00000001e0b76214 C663D847-B94F-3FB0-9254-32EDBC55315E + 49684
	23  libdispatch.dylib                   0x00000001e0b80e10 C663D847-B94F-3FB0-9254-32EDBC55315E + 93712
	24  libsystem_pthread.dylib             0x0000000226010df8 _pthread_wqthread + 288
	25  libsystem_pthread.dylib             0x0000000226010b98 start_wqthread + 8
)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported value for standard codec'
*** First throw call stack:
(0x1d96f2248 0x1d2ab7a68 0x1d407681c 0x1069ec740 0x1069e96e0 0x103e61800 0x103e6376c 0x103e639dc 0x1edf34140 0x1edf36c5c 0x1ee00499c 0x1edf47b94 0x1d975ca14 0x1d9708f2c 0x1d3bd0d38 0x1d3ba22fc 0x1d417cf44 0x2260713e4 0x226064580 0x1e0b6e05c 0x1e0b8bf58 0x1e0b7556c 0x1e0b76214 0x1e0b80e10 0x226010df8 0x226010b98)
libc++abi: terminating with uncaught exception of type NSException
* thread #3, queue = 'com.apple.NSXPCConnection.m-user.com.apple.photos.service', stop reason = signal SIGABRT
    frame #0: 0x0000000215dda200 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`:
->  0x215dda200 <+8>:  b.lo   0x215dda220               ; <+40>
    0x215dda204 <+12>: pacibsp
    0x215dda208 <+16>: stp    x29, x30, [sp, #-0x10]!
    0x215dda20c <+20>: mov    x29, sp
Target 0: (Runner) stopped.
Lost connection to device.
Exited

Понравилась статья? Поделить с друзьями:
  • Php5ts dll ошибка
  • Php фатальная ошибка yii base errorexception
  • Php уровни ошибок
  • Php увидеть ошибки
  • Php убрать показ ошибок