private void dispatch(String[] commands, Socket s) throws IOException {
        PrintWriter writer = new PrintWriter(s.getOutputStream(), true);

        switch (commands[0]) {
            case AppConstants.GET:
                if (commands.length != 2) {
                    LOG.warning("Insufficient parameters for GET command");
                    writer.println(AppConstants.FILENOTFOUND);
                    break;
                }

                String fileName = commands[1];
                File f = new File(BASE_DIR + fileName);

                if (!f.isFile()) {
                    writer.println(AppConstants.FILENOTFOUND);
                    LOG.info("File not found on client");
                } else if (f.length() > Integer.MAX_VALUE) { //imposing a limit on the size of data that can be transferred
                    writer.println(AppConstants.FILENOTFOUND);
                    LOG.warning("File requested was too large to be transferred");
                } else {
                    writer.println(AppConstants.FILE);
                    try (FileInputStream file = new FileInputStream(f); BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream())) {
                        byte[] buffer = new byte[1024];
                        int count;

                        LOG.info("Sending file");

                        long uploadTimeStart = System.currentTimeMillis();

                        while ((count = file.read(buffer)) > 0) {
                            bos.write(buffer, 0, count);
                            bos.flush();
                        }

                        long uploadTime = System.currentTimeMillis() - uploadTimeStart;
                        LOG.log(Level.INFO, "File sent in {0}ms", uploadTime);
                    }

                }
                break;
            default:
                LOG.log(Level.WARNING, "Unknown command: {0}", commands[0]);
        }

    }