-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add code for handling conversion from filename or filpath to MIME type #29
Conversation
…nly static methods
Currently there are no checks to confirm that the argument is valid in any of the methods. Maybe this could be added later on? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Everything from using the correct type and sub-type pair to the tests done for the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the changes to pom.xml needed? The current file already contains specification for java version 17.
The files test.html and test.pfd in test folder, can we do without them? Does Paths.get really need an existing file to work?
The changes in pom.xml were made accedently, good catch! I also removed the files that were used during testing, they are indeed unnecessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to end files with a newline. Helps diff tools to see changes at end of file.
https://stackoverflow.com/questions/4700312/empty-new-line-at-the-end-of-the-java-source-files
src/test/java/org/fungover/storm/fileHandler/FormatConverterTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Martin Blomberg <martin.blomberg@outlook.com>
Co-authored-by: Martin Blomberg <martin.blomberg@outlook.com>
…st.java Co-authored-by: Martin Blomberg <martin.blomberg@outlook.com>
Good to know! |
So what happens if we have a filetype not in the list? Is there a default type like text or something we could use? text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data. |
Support for default MIME type have been added |
This looks great @helenahalldiniths! I am not sure if we should add conversions for the common file types such as |
String[] result = file.split("\\."); | ||
String subtype = result[result.length - 1]; | ||
Optional<String> type = Optional.ofNullable(subtypeToType.get(subtype)); | ||
if (type.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be simplified using one of the methods on Optional type variables like orElse orElseGet ? Might need to store the complete type string and not only subtype maybe for that to work?
This can always be updated according to the file types that we need. |
This vill fix #12