The code for checking prefixes and applying multipliers is clearly duplicated. It would make sense to move it into a function, which would, say, take the value and the prefix as strings, bools for whether kb and mb are allowed, and return the parsed value in bytes, or throw an exception otherwise.