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

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

iOS App Development: How Apple's iOS 13 & Swift 5 Will Change App Development Industry

Want to know how Apple's iOS 13 & Swift 5 will change the iOS app development industry? Refer to this blog that contains in-detail information on it.

How To Build Reminders iOS App in Swift 5 for Beginners

In this video, we build the Reminders App in Swift for iOS. Learn how to use dates, local / user notifications, tableviews, and much more. From scratch to working app, we'll go over every step up toe process together.

Creating an iOS app with user presence using Node.js and Swift

In this tutorial, we are going to see how you can add user presence to an iOS application using Pusher Channels, Node.js, and Swift.