amosavian / FileProvider

FileManager replacement for Local, iCloud and Remote (WebDAV/FTP/Dropbox/OneDrive) files -- Swift
MIT License
56 stars 14 forks source link

FTPFileProvider return Error Domain=NSPOSIXErrorDomain for files over 5gb #183

Open nastasiupta opened 1 year ago

nastasiupta commented 1 year ago

Everything works perfect for smaller files, I tested it with bigger batch files etc, but it's not working properly for a big file. I'm using copy method to download the file to user's mac.

let credential = URLCredential(user: ftpCredentials.username, password: ftpCredentials.password, persistence: .permanent)
var components = URLComponents()
components.host = ftpCredentials.host
components.scheme = "ftp"
if let portInt = Int(ftpCredentials.port) {
    components.port = portInt
}
guard let url = components.url,
      let fileProvider = FTPFileProvider(baseURL: url, mode: ftpCredentials.passiveConnection ? .passive : .active, credential: credential) else { return }
data.fileProvider.copyItem(path: data.object.path, toLocalURL: data.fileDestinationURL, completionHandler: { [weak self] error in
    DispatchQueue.main.async {
        guard let strongSelf = self else { return }
        if let error = error {
            completion?(error.localizedDescription, .init(request: data, newFileStatus: .errorOccured))
        } else {
            completion?(nil, .init(newFileStatus: .mediaUploadPending))
        }
    }
})

Also, I noticed that the file is not displayed during the download, but it is at the end, can this be changed? During the copy operation, looks like the file is loaded in the RAM memory ... I think if there is an option to solve the issue mentioned above, we can also limit de amount of ram allocation.

Printing description of error:
▿ Optional<Error>
  - some : Error Domain=NSPOSIXErrorDomain Code=22 "Invalid argument" UserInfo={_kCFStreamErrorCodeKey=22, _kCFStreamErrorDomainKey=1}