Explorar o código

Fixing the download of files with standard extensions (xopp, csv,
drawio).

Lucas Albertins %!s(int64=2) %!d(string=hai) anos
pai
achega
5dcb5da563

+ 8 - 0
src/main/java/ua/be/wee/model/pt/TraceArtifact.java

@@ -106,4 +106,12 @@ public class TraceArtifact {
 	public void setNextVersion(TraceArtifact nextVersion) {
 		this.nextVersion = nextVersion;
 	}
+	
+	public String getFileExtension() {
+		if (location != null && !location.equals("")) {
+			String ext = location.substring(location.lastIndexOf(".")+1);
+			return ext;
+		}
+		return null;
+	}
 }

+ 3 - 2
src/main/resources/templates/enact.html

@@ -77,8 +77,9 @@
             <div class="content">
               <p>
                 <strong th:text="${art.relatesTo.name}"></strong> <small th:text="${art.relatesTo.type}"></small>
-                <br>
-                <a th:href="@{|${storageURL}/files/file/${art.location}|}">Download</a>
+                <br>                
+                <a th:if="${art.fileExtension == 'xopp' || art.fileExtension == 'csv' || art.fileExtension == 'drawio'}" th:href="@{|${storageURL}/files/${art.fileExtension}/${art.location}|}">Download</a>
+                <a th:if="${art.fileExtension != null && art.fileExtension != 'xopp' && art.fileExtension != 'csv' && art.fileExtension != 'drawio'}" th:href="@{|${storageURL}/files/file/${art.location}|}">Download</a>                
               </p>
             </div>
           </div>