【问题标题】:upload image from ios swift 3 to jsp web service将图像从 ios swift 3 上传到 jsp Web 服务
【发布时间】:2017-01-24 12:01:03
【问题描述】:

嘿,我想将图像从 IOS (swift3) 上传到 JSP Web 服务并将图像保存在 Web 服务存储中(如果在 web-inf 中会更好)和 mysql 数据库的路径任何人都可以帮助我或发送我举个例子

还是谢谢

【问题讨论】:

    标签: ios json jsp jakarta-ee swift3


    【解决方案1】:

    对于 Swift 部分,通常的做法是将图像转换为 base64String

    let image = UIImage(named:"test")
    
    // Convert to PNG if you need lossless
    if let pngBase64String = UIImagePNGRepresentation(image)?.base64EncodedString() {
       // upload pngBase64String to server         
    }
    
    // or Convert to JPG        
    let jpegCompressionQuality: CGFloat = 0.9
    if let jpgBase64String = UIImageJPEGRepresentation(image, jpegCompressionQuality)?.base64EncodedString() {
        // Upload jpgBase64String to server
    }
    

    【讨论】:

    • 谢谢我知道,但我想要整个包 iphone 端和服务器端
    猜你喜欢
    • 2017-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-22
    • 1970-01-01
    • 2018-01-19
    相关资源
    最近更新 更多