Commit 907f8a78 by xmh

对 上传的文件 做xml判断

1 parent 7a5593db
......@@ -3,6 +3,7 @@ package com.viontech.storage.controller;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FastByteArrayOutputStream;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.XmlUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.viontech.storage.entity.Context;
......@@ -17,9 +18,12 @@ import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
......@@ -121,8 +125,10 @@ public class StorageConfigController {
@PostMapping("/upload")
public Message<Object> upload(Long id, MultipartFile file) throws IOException {
FastByteArrayOutputStream read = IoUtil.read(file.getInputStream());
StorageConfig byId = storageConfigService.getById(id).setContext(null).setType(1).setConfig(read.toByteArray());
byte[] bytes = read.toByteArray();
Document document = XmlUtil.readXML(new ByteArrayInputStream(bytes));
StorageConfig byId = storageConfigService.getById(id).setContext(null).setType(1).setConfig(bytes);
storageConfigService.updateById(byId);
return Message.success();
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!