SDK DJI download photo in swift

SDK DJI download photo in swift

I am simply attempting to download the latest access the feed from my DJI drone and convert the feed into a UIImage. The easiest way i thought this could be done is take a photo, then promptly afterwards download the latest photo from the storage. I will add the download from storage code below. Is this the easiest way? I have been receiving this error code -

I am simply attempting to download the latest access the feed from my DJI drone and convert the feed into a UIImage. The easiest way i thought this could be done is take a photo, then promptly afterwards download the latest photo from the storage. I will add the download from storage code below. Is this the easiest way? I have been receiving this error code -

Settings parameters operation failed. (Code : -1007)

I've researched but couldn't find what this meant - The DJI docs are limited to pretty much all obj-c. Here the code -

@IBAction func download(_ sender: UIButton) {
    let camera = self.fetchCamera()

// switch camera mode to allow for media downloads
camera?.setMode(DJICameraMode.mediaDownload, withCompletion: {(error) in
    if error != nil {
        self.status.text="\(error!.localizedDescription)"
    }
    else {

        // get the media manager from the drone to gain access to the files
        let manager = camera!.mediaManager!

            if error != nil {
                self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
                self.status.text = "Error refreshing list: \(error)"

            }
            else {
                print("Refreshed file list")
                print("State: \(manager.sdCardFileListState.rawValue)")


                guard let files = manager.sdCardFileListSnapshot() else {
                    self.status.text = ("No files to download")
                    return
                }

                self.status.text = "There are files to download"

                var images: [UIImage] = []

                for file in files {

                    if file.mediaType == .JPEG {

                        self.status.text = ("Time created: \(file.timeCreated)")

                        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

                            file.fetchData(withOffset: 0, update: DispatchQueue.main, update: {(_ data: Data?, _ isComplete: Bool, _ error: Error?) -> Void in

                                if error != nil {
                                    self.status.text = "State: \(manager.sdCardFileListState.rawValue)"
                                    self.status.text = "Error downloading photo: \(error!)"
                                }
                                else {
                                    // unwrap downloaded data and create image
                                    if let data = data, let downloadedImage = UIImage(data: data) {
                                        self.status.text = "Image was downloaded!"
                                        images.append( downloadedImage )
                                    }
                                }

                            }) // end of filedata fetch

                        }

                    }

                } // end of loop


            }

    }

})// end of camera setMode block

}`

Any help would be greatly appreciated - Thanks

ios swift

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Hire Dedicated Swift Developers

Want to create a native iOS application for your Startup? **[Hire Dedicated Swift Developers](https://hourlydeveloper.io/hire-dedicated-swift-developer/ "Hire Dedicated Swift Developers")** for end-to-end services like development, migration...

10 Free Online Resources To Learn Swift Language

Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated.

Hire iOS App Developer

Are you looking to transform your idea into an iPhone application? Hire iPhone programmer team from **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** to ensure the best results, utilizing all the latest trends in iOS app...

HOW TO BUILD CUSTOM ALERT DIALOG BOX FROM SCRATCH STEP BY STEP USING SWIFT iOS XCODE 11.4

Topic: HOW TO BUILD CUSTOM ALERT DIALOG BOX FROM SCRATCH STEP BY STEP USING SWIFT iOS XCODE 11.4 Subscribe Us: http://bit.ly/2UaSC5s Find us on: Discord: htt...

Swift iOS BackgroundTasks framework — Background App Refresh in 4 Steps

IOS allows app to refresh it content even when it is sent to background. iOS can intelligently study the user’s behaviour and schedule background tasks to the moment right before routine usage.