图像上载不工作,iOS Swift多部分

图像上载不工作,iOS Swift多部分,swift,alamofire,image-uploading,multipartform-data,Swift,Alamofire,Image Uploading,Multipartform Data,我必须上传一张图片到服务器上,但我的行为异常 if let imgdata = UIImageJPEGRepresentation(#imageLiteral(resourceName: "vishal"), 0.2) { let headers: HTTPHeaders = [ "token": authToken, "Content-type": "multipart/form-data" ]

我必须上传一张图片到服务器上,但我的行为异常

if let imgdata = UIImageJPEGRepresentation(#imageLiteral(resourceName: "vishal"), 0.2) {

        let headers: HTTPHeaders = [
            "token": authToken,
            "Content-type": "multipart/form-data"
        ]

        Alamofire.upload(multipartFormData: { (multipartFormData) in
            multipartFormData.append(imgdata, withName: "image", fileName: "image.png", mimeType: "image/png")
        }, usingThreshold: UInt64.init(), to: url, method: .patch, headers: headers) { (result) in
            switch result{
            case .success(let upload, _, _):
                upload.responseJSON { response in
                    print("Succesfully uploaded")
                    if let _ = response.error{
                        return
                    }
                    if let value = response.result.value {
                        let json = JSON(value)
                        print(json)
                    }
                }
            case .failure(let error):
                print("Error in upload: \(error.localizedDescription)")
            }
        }
    }
在一个新项目中,该代码运行良好,并将映像上载到服务器,但在我的旧项目中,对于相同的代码,api调用成功,但映像未上载


请帮助

方法类型是补丁,它将被放置或发布。在新的xcode项目中,精确的代码可以正常工作