constantine-fry / rebekka

Rebekka - FTP/FTPS client in Swift.
BSD 2-Clause "Simplified" License
87 stars 56 forks source link

Local FTP Server? #5

Closed BinaryZeph closed 8 years ago

BinaryZeph commented 8 years ago

Hello,

Wondering if you've seen or heard of this before. Everything works fine in my app if I upload from my home wifi, or on cellular data from the phone.

Oddly though, when I'm at the office the files do not upload. The result from the session comes back true with no errors. I've checked the FTP server log and when I'm local I see the phone connecting, but the connection is then just closed, no errors, and the app never seems to actually try to perform the upload.

Any thoughts? I'm 100% stumped.

func doUpload(){ print (photos.count)

    var configuration = SessionConfiguration()
    configuration.host = (config["ftpIP"] as? String)!
    configuration.username = (config["ftpUser"] as? String)!
    configuration.password = (config["ftpPass"] as? String)!
    let session = Session(configuration: configuration)

    //Loop through all the photos

    for (index,currentPhoto) in photos.enumerate() {
        //Load the photo into the FTP handler
        let DocumentsDirectory = NSFileManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!
        let UploadPhotoURL = DocumentsDirectory.URLByAppendingPathComponent("photos/"+currentPhoto.fileName)

        session.upload(UploadPhotoURL, path: currentPhoto.fileName) {
            (result, error) -> Void in
            print("\nUpload file with result: \(result), error: \(error)")

            if (result == true){
                self.photos[index].uploaded = true
            }

            if(session.operationQueue.operationCount == 0){
                self.cleanupPhotos()
            }
        }
    }
}
Pr0gmaT1k commented 8 years ago

If i understand, you got the problem when you do: Office ==> Upload ==> Office and everything ok when you do: Home ==> Upload ==> Office and: Cellular ==> Upload ==> Office ?

Any firewall restrictions ? If the same code work on Home / Cellular the problem is your office.