"The file “command.cgi” couldn’t be opened."

154 Views Asked by At

FlashAir W-04 Fourth Generation SD memory card

In my iOS app directory listing api not working.

Response :

Task .<0> HTTP load failed (error code: -1003 [12:8])

2019-05-21 23:32:40.267572+0530 Razzo[10489:87069] NSURLConnection finished with error - code -1003

Error Domain=NSCocoaErrorDomain Code=256 "The file “command.cgi” couldn’t be opened." UserInfo={NSURL=http://flashair/command.cgi?op=100&DIR=/DCIM}

Please help me what was wrong

below code snippet

private func getdata() {
        let url100 = URL(string: "http://flashair/command.cgi?op=100&DIR=/DCIM")
        var dirStr: String? = nil
        do {
            if let url100 = url100 {
                dirStr = try String(contentsOf: url100, encoding: String.Encoding(rawValue: String.Encoding.utf8.rawValue))
                if let dir = dirStr {
                    arrayfiles = dir.components(separatedBy: "\n")
                }
                tblContent.reloadData()
            }
        } catch {
            print(error)
            self.displayAlert(message: error.localizedDescription)
        }
}

Config file below

[Vendor]

CIPATH=/DCIM/100__TSB/FA000001.JPG

APPMODE=4

APPNETWORKKEY=12345678

VERSION=F15DBW3BW4.00.03

CID=02544d535733324755e3c6dc7b012301

PRODUCT=FlashAir

VENDOR=TOSHIBA

MASTERCODE=f437b71e0e4f

LOCK=1

1

There are 1 best solutions below

2
matt On

contentsOf: url100 would be for a local file URL. You are not providing a valid file URL.

If your file is remote you need to download the file as data with URLSession. If it is local you need to work out its file URL.