Swift中的Alamofire分段上传帖子错误 [英] Alamofire multipart upload post error in Swift

查看:118
本文介绍了Swift中的Alamofire分段上传帖子错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Alamofire上传图片时,我收到错误.POST



我附上一张图片以显示错误





如果您不使用 cocoapods 只需打开 Alamofire 文件夹,转到源文件夹和mak确定你也有相同的文件



如果你没有找到 MultipartFormData.swift 这意味着你的Alamofire版本不支持MultipartFormData,那么您需要从 Alamofire 获取最新版本,或者如果您使用 cocoapods 您必须更新 Alamofire pod 的行在 podfile 就像这样

  platform:ios,'8.0' 
use_frameworks!

目标'ProjectName'做

pod'Alamofire',:git => 'https://github.com/Alamofire/Alamofire.git',: branch => 'master'

end
target'ProjectNameTests'do
end

更新你的pod文件后你需要运行这个命令来更新cocoapods项目

  pod install --verbose 


When i tried to upload image using Alamofire I'm getting error in .POST

Im attaching an image along with this to show the error

(http://www.awesomescreenshot.com/image/422237/0d5fe4a4b486b14fdf52f8ca26d22bea)

解决方案

I had the same problem , as Michal said it's an installation issue if you are using cocoapods go to your project files/pods/Alamofires/Source and make sure you have 9 files there just like this image and make sure that the MultipartFormData.swift file is there

if you are not using cocoapods just open the Alamofire folder and go to source folder and make sure you have the same files there too

if you didn't find MultipartFormData.swift that means that your Alamofire version does not support MultipartFormData then you will need to get the latest version from here Alamofire or if you use cocoapods you will have to update the line of Alamofire pod on podfile to be like this

platform :ios, '8.0'
use_frameworks!

target 'ProjectName' do

pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'master'

end
target 'ProjectNameTests' do
end

after updating your pod file you need to run this command to update the cocoapods project

pod install --verbose

这篇关于Swift中的Alamofire分段上传帖子错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆