swiftalamofirealamofire5

Alamofire upload progress


I am completely new in Alamofire (and in Swift in general). And I need to get the realtime upload progress. How to achieve that?

Here I am uploading multiple PDF documents :

AF.upload(multipartFormData: { multipartFormData in
    for f in files{
        multipartFormData.append(f.data, withName: "files", fileName: f.name, mimeType: "application/pdf")
    }
}, to: "http://localhost:8080/api/v1/documents")
.uploadProgress { progress in
    print("Upload Progress: \(progress.fractionCompleted)")
}

Here it only outputs, which is not what I expect

Upload Progress: 1.0

So is this documentation lying? https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#upload-progress


Solution

  • Maybe your file is too small, try a larger file.