3 Replies
      Latest reply: Jan 15, 2017 9:04 AM by eskimo RSS
      biondo-giuseppe Level 1 Level 1 (0 points)

        I have several pictures stored in an hard drive attached to the Apple AirPort Extreme.

        The paths of the pictures look like the following:

         

        "afp://AirPort Extreme 3 (TC)._afpovertcp._tcp.local/NAS-0/00024000000/00024000023.jpg"

         

        How can I load and display them in the iPad with Swift Code ?

        I wish to download and display them from a Local network only, no web or internet server.

        Xcode 8.2.1 SWIFT 3.0

         

        This is the code I am using to display images.

        It works with files stored in a local Hard Drive (USB port) as file:///Volumes but it does not work when the file is stored to the Time Capsule as afp://...etc file

         

           // Get data from url

            func getDataFromUrl(url: URL, completion: @escaping (_ data: Data?, _  response: URLResponse?, _ error: Error?) -> Void) {

                URLSession.shared.dataTask(with: url) {

                    (data, response, error) in

                    completion(data, response, error)

                    }.resume()

            }

            // Load the image

            func downloadImage(url: URL) {

                getDataFromUrl(url: url) { (data, response, error)  in

                    guard let data = data, error == nil else { return }

                    DispatchQueue.main.async() { () -> Void in

                        self.NewPic.image = UIImage(data: data)

                    }

                }

            }

            // Display the piture when action detected

            @IBAction func UrlButton(_ sender: Any) {

               traditionalAddress = "afp://AirPort Extreme 3 (TC)._afpovertcp._tcp.local/NAS-0/00024000000/00024000023.jpg"

               let newUrl = traditionalAddress.replacingOccurrences(of: " ", with: "%20", options: .literal, range: nil)

                if let checkedUrl = URL(string: newUrl) {

                    downloadImage(url: checkedUrl)

                }

            }

        • Re: Url for Time Capsule files afp://
          eskimo Apple Staff Apple Staff (6,470 points)

          How can I load and display them in the iPad with Swift Code ?

          For this it work you will need an Apple Filing Protocol (AFP) implementation on the iPad.  There is no such implementation built in, so you’d need to either write or acquire one.  Writing one from scratch is possible but very hard.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"