Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
1.2 kB
3
Indexable
Never
 @PostMapping("/file")
    public ResponseEntity<String> requestPush(@RequestBody MultipartFile file) throws Exception {
        // check != .csv

        private static Logger LOGGER = LoggerFactory.getLogger(FCMConfig.class);

        try (BufferedReader reader = new BufferedReader(new InputStreamReader(file.getInputStream()))) {
            Map<String, Set<String>> clientIPMap = new HashMap<>();
            String line;
            String cvsSplitBy = "\t";

            while ((line = (reader.readLine())) != null) {
                String[] data = line.split(cvsSplitBy);
                String aid = data[0];
                String ip = data[1];
                if (!clientIPMap.containsKey(aid)) {
                    clientIPMap.put(aid, new HashSet<>());
                }
                clientIPMap.get(aid).add(ip);
            }

            for (Map.Entry<String, Set<String>> entry : clientIPMap.entrySet()) {
                ApplicationManager.getInstance().setInHashset(entry
                        .getKey(), entry.getValue());
            }
        } catch (IOException e) {
            LOGGER.error("Test Send Exception : {}", e);
        }
        return ResponseEntity.ok("hehe");
    }
Leave a Comment