Skip to content

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

Open
@nastasiupta

Description

@nastasiupta

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}

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