赞
踩
流水账代码:
- public class ImagetoImageUrlUtil {
-
- private static final Logger logger = Logger
- .getLogger(ImagetoImageUrlUtil.class);
-
- @Autowired
- private static int MAXSIZE = 1024 * 1024 * 4;
-
- public static String upLoadImage(String image,String uploadPath,String readPath) {
- FileOutputStream fos = null;
- BufferedOutputStream bos = null;
- String newFileName = new SimpleDateFormat("yyyyMMddHHmmssSSS")
- .format(new Date())
- + "_"
- + new Random().nextInt(10000)
- +"."
- + image.split(",")[0].split("/")[1].split(";")[0];
- try {
- byte[] photoimg = new BASE64Decoder().decodeBuffer(image.split(",")[1]);
- for (int i = 0; i < photoimg.length; ++i) {
- if (photoimg[i] < 0) {
- // 调整异常数据
- photoimg[i] += 256;
- }
- }
- System.out.println("图片的大小:" + photoimg.length);
- logger.info("uploadPath :" + uploadPath);
- logger.info("readPath :" + readPath);
- if (photoimg.length < MAXSIZE) {
- fos = new FileOutputStream(new File(uploadPath + newFileName));
- bos = new BufferedOutputStream(fos);
- bos.write(photoimg);
- } else {
- throw new Exception("图片大小不能超过4M");
- }
- } catch (Exception e) {
- logger.info("Exception" + e.getMessage());
- e.printStackTrace();
- } finally {
- if (bos != null) {
- try {
- bos.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- }
- }
- String pictureUrl = readPath + newFileName;
- return pictureUrl;
- }
- public static void main(String[] args) {
-
- ImagetoImageUrlUtil.upLoadImage("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAAI+CAYAAADjM6ekAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAB3RJTUUH4AcKFBE6ifd8WAAAgABJREFUeNrt/W+MG9eB53v/KLVs0mnFpCInzYw1Y2asHbcmvk9aUO5ua50X0S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vqqKipIM9LCD7+vhm3LWmt38119fVUzGzc0XXjx+9KEtLS8FO+12UdWZWwB2Kif0NPPtAPA04+3pwt/vxkuFf5+IwRMoBP4dc1rqFCKlsif+MN28HTy71Z1YF9eCxfa4/8d/3x+Y9jDzXrmJ/J66nvVzkCIfmbvLWv5xzXlJws6uL8s27ZVu95QMS9NV9rdVlcvW7JsqTxVUqWcl1W3ZVl1zU6bW5md/WFNl67k9eifP6WzL51Xw2rXzpZUvbYqqR1cqilZtqWZfUdUbzZ05IU/0MXH/L/FWDt6XI1vL6r8b5+SSgdUe+Gs7Gs1le4/oqk/Od6zvmVLtS+eVKVY9C1z9aqlh/7irP7mGw9q8eUVSVJ5qt1l+PDMYZXvKmvhxfN6+AvHVCgUtPBie0zAwzOHfcus/HhVUl71jfEX7Y0QsGxbWt047vLUlCqVikqTJdl2XSvWmrFV48Ofe1RPvTgv64Y0NZlXpdgbPi6uLOrBmQd1eHpOT/1fJzW119LDnzkprUd6WQEAAAAAIiiUugM/L9My9zZRP/sD48i2XflTUyrk81qpViVJ1VpVs6W5zuK8d/0I8lLirKorarGbmzs+/qV2mHT68TOym7bqf9hdKbt
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。