小程序base64图片解析成流上传服务器

时间:2019-04-01 14:11:45   收藏:0   阅读:250

/**
*
* @Title: decodeBase64ToImage
* @Description: (將base64位的图片解码成流 上传到阿里云服务器)
* @param base64 图片的64进制码
* @param path 图片的本地生成地址
* @param imgName 图片名称
* @param uppath 图片的oss远程地址
* @param imgName void (这里描述输出参数的作用)
* @throws
* @author huyuhang
* @date 2019年3月12日 下午4:53:44
*/
public static void decodeBase64ToImage(String base64,String uppath) {
BASE64Decoder decoder = new BASE64Decoder();
byte[] decoderBytes;
try {
decoderBytes = decoder.decodeBuffer(base64);
ByteArrayInputStream inputStream = new ByteArrayInputStream(decoderBytes);
//上传到oss
if (uppath.startsWith("/")) {
uppath = uppath.substring(1);
}

//上传阿里云
//ossUtil.putObjectMethod(uppath,inputStream);
} catch (IOException e) {
e.printStackTrace();
}

}

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!