Skip to content
//获取base64长字符串
String base64 = param.getData().substring(param.getData().lastIndexOf(",") + 1);
//生成新名称
String newName = UUID.randomUUID().toString();

try {
    //将base64字符串转成byte文件
    //new BASE64Decoder().decodeBuffer(base64);
    byte[] data = new BASE64Decoder().decodeBuffer(base64);	
    //检测修改byte文件
    for (int i = 0; i < data.length; ++i) {
        if (data[i] < 0) {
            data[i] += 256;
        }
    }
    //文件写入本地
    OutputStream out = new FileOutputStream(this.path + newName + ".jpeg");
    out.write(data);
    out.flush();
    out.close();
    //
    
    //存入数据库
    //
    
    //返回成功url或图片id
} catch (Exception e) {
    //上传失败
}