Skip to content

Problems when Attempting to Download #66

@anonymouz4

Description

@anonymouz4

Something fails here even though I think I did everything properly.
It just returns Unable to connect to share.

The session and the filepath are vailid and transferred fine to the Dl-Handler.
I also know that the Handler-Function gets executed (I printed something inside there)

Download Handler:

public class BackgroundTasks: NSObject, TOSMBSessionDownloadTaskDelegate {
    
    var downloadSession: TOSMBSession?
    var downloadTask: TOSMBSessionDownloadTask?
    var filePath: String?
    
    public func downloadFile(from session: TOSMBSession?, atFilePath filePath: String) {
   
        self.downloadSession = session
        self.downloadTask = session?.downloadTaskForFile(atPath: filePath, destinationPath: nil, delegate: self)
        self.downloadTask?.resume()
        print(downloadTask?.countOfBytesExpectedToReceive) //-> Returns 0
    }
    
    public func downloadTask(_ downloadTask: TOSMBSessionDownloadTask?, didWriteBytes bytesWritten: UInt64, totalBytesReceived: UInt64, totalBytesExpectedToReceive totalBytesToReceive: Int64) {
        
        print("downloadTask - didWriteBytes - \(bytesWritten)")
        print("downloadTask - totalBytesReceived - \(totalBytesReceived)")
        print("downloadTask - totalBytesExpectedToReceive - \(totalBytesToReceive)")
    }
}

Call:
–> From Different ViewController
BackgroundTasks().downloadFile(from: session, atFilePath: editItems![0].filePath!)

If I do the complex call with own handlers and without extra class, than I also get a Could not Connect Error

This is really important for me bc my whole app is complete besides the downloading.
If anyone has an idea I would very appreciate it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions