@Override
	public void run() {
		
		try {
			try{
				String status;
				String commandResponse = Protocol.UP_CS_RESPONSE;
				String[] tokens = _message.getStrParams();
				byte[] data = _message.getData();
				String filename = tokens[1];
				int filesize = Integer.parseInt(tokens[2]);
				File file = new File(LocalPaths.RESOURCES + filename);
				if(file.exists()){
					status = "nok";
					System.out.println(Errors.FILE_EXISTS);
				}
				else{
					FileHandler.createFile(LocalPaths.STORED + filename, filesize, data);
					if(file.exists()){
						if(file.length() == filesize){
							status = "ok";
						}
						else{
							status= "nok";
							System.err.println(Errors.SAVING_FILE);
						}
					}
					else{
						status= "nok";
						System.err.println(Errors.INEXISTING_FILE);
					}
				}
				String toEcho = commandResponse + " " + status;
				System.out.println(toEcho);
				_server.send(toEcho);
				System.exit(0);
			} catch(NumberFormatException e){
				_server.send(Protocol.ERROR);
				System.err.println(Errors.INVALID_PROTOCOL);
				
			} catch(IllegalArgumentException e){
				_server.send(Protocol.ERROR);
				System.err.println(Errors.INVALID_PROTOCOL);
				
			} catch(SocketException e){
				_server.send(Protocol.ERROR);
				System.err.println(Errors.SOCKET_PROBLEM);
				
			} catch(IOException e){
				_server.send(Protocol.ERROR);
				System.err.println(Errors.IO_PROBLEM);
			}
		} catch(IOException e){
			System.err.println(Errors.SOCKET_PROBLEM);
			System.exit(-1);
		}
		System.exit(0);
	}