Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to follow the upload's progress ? #158

Open
xavierburzig opened this issue Oct 25, 2019 · 1 comment
Open

Any way to follow the upload's progress ? #158

xavierburzig opened this issue Oct 25, 2019 · 1 comment

Comments

@xavierburzig
Copy link

Hi everybody,

I'm currently using your FileProvider to write files in a non-secure FTP server and I actually got a working code

let filename = "test.txt" print("Test started:.") let data = "Hello world".data(using: .ascii) self.documentsProvider?.writeContents(path: self.ftpPathPhotos + "/" + filename, contents: data, overwrite: true) { (error) in if let theError = error { print("error = \(theError)") } else { print("alllllllright") } }

Question is :
I was wondering if there is any way to follow the upload's progression, cause I saw in your source repo that you've got something close but I can't figure it out ?

In advance cheers and have a great day

Xavier

@raaowx
Copy link

raaowx commented Jun 4, 2020

Hi,

You need the provider's delegate. Example:

import FilesProvider

class WhatEver: UIViewController or Whatever, FileProviderDelegate {
  // Here you have your stuff
  // The important thing is to implement 'FileProviderDelegate'
  // Then in code you will create the object using something like:
  documentsProvider = FTPFileProvider(baseURL: your_url, mode: .your_mode, credential: your_credentials, cache: .your_cache_manage)
  // After that, do:
  documentsProvider.delegate = self // This will delegate some FilesProvider function to this class

  // You will need to add the following stubs from the 'FileProviderDelegate'
  func fileproviderSucceed(_ fileProvider: FileProviderOperations, operation: FileOperationType) {
    // Called when transaction finish successfully
  }

  func fileproviderFailed(_ fileProvider: FileProviderOperations, operation: FileOperationType, error: Error) {
    // Called when there's some kind of error in the transaction
  }
  
  func fileproviderProgress(_ fileProvider: FileProviderOperations, operation: FileOperationType, progress: Float) {
    // This is the one you want. Called with the progress. It is a float that goes from 0.0 to 1.0
  }

}

With that delegate you will be able to manage the progress of the transactions. Upload and download.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants