-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[kbss-cvut/termit-ui#449] Modify Excel template download so that it (…
…hopefully) works also in a Docker container.
- Loading branch information
Showing
5 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/cz/cvut/kbss/termit/util/TypeAwareClasspathResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cz.cvut.kbss.termit.util; | ||
|
||
import org.springframework.core.io.ClassPathResource; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* Implementation of {@link TypeAwareResource} for files on classpath. | ||
*/ | ||
public class TypeAwareClasspathResource extends ClassPathResource implements TypeAwareResource { | ||
|
||
private final String mediaType; | ||
|
||
public TypeAwareClasspathResource(String path, String mediaType) { | ||
super(path); | ||
this.mediaType = mediaType; | ||
} | ||
|
||
@Override | ||
public Optional<String> getMediaType() { | ||
return Optional.ofNullable(mediaType); | ||
} | ||
|
||
@Override | ||
public Optional<String> getFileExtension() { | ||
return getPath().contains(".") ? Optional.of(getPath().substring(getPath().lastIndexOf("."))) : | ||
Optional.empty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters