简体   繁体   English

Alamofire 上传进度

[英]Alamofire upload progress

I am completely new in Alamofire (and in Swift in general).我对 Alamofire(以及一般的 Swift)完全陌生。 And I need to get the realtime upload progress .我需要获取实时上传进度 How to achieve that?如何做到这一点?

Here I am uploading multiple PDF documents :我在这里上传多个 PDF 文档:

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 https://github.com/Alamofire/Alamofire/blob/master/Documentation/Usage.md#upload-progress

也许您的文件太小,请尝试使用更大的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM