Skip to content

Commit

Permalink
Merge pull request #7266 from IQSS/7265-original-file-extensions
Browse files Browse the repository at this point in the history
File extensions missing for some original downloads
  • Loading branch information
kcondon authored Sep 15, 2020
2 parents c7d63c1 + 5ef1710 commit dbf0bca
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/java/edu/harvard/iq/dataverse/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -695,21 +695,27 @@ private static String checksumDigestToString(byte[] digestBytes) {
}

public static String generateOriginalExtension(String fileType) {

if (fileType.equalsIgnoreCase("application/x-spss-sav")) {
return ".sav";
} else if (fileType.equalsIgnoreCase("application/x-spss-por")) {
return ".por";
} else if (fileType.equalsIgnoreCase("application/x-stata")) {
return ".por";
// in addition to "application/x-stata" we want to support
// "application/x-stata-13" ... etc.:
} else if (fileType.toLowerCase().startsWith("application/x-stata")) {
return ".dta";
} else if (fileType.equalsIgnoreCase( "application/x-rlang-transport")) {
} else if (fileType.equalsIgnoreCase("application/x-dvn-csvspss-zip")) {
return ".zip";
} else if (fileType.equalsIgnoreCase("application/x-dvn-tabddi-zip")) {
return ".zip";
} else if (fileType.equalsIgnoreCase("application/x-rlang-transport")) {
return ".RData";
} else if (fileType.equalsIgnoreCase("text/csv")) {
} else if (fileType.equalsIgnoreCase("text/csv") || fileType.equalsIgnoreCase("text/comma-separated-values")) {
return ".csv";
} else if (fileType.equalsIgnoreCase( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
} else if (fileType.equalsIgnoreCase("text/tsv") || fileType.equalsIgnoreCase("text/tab-separated-values")) {
return ".tsv";
} else if (fileType.equalsIgnoreCase("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {
return ".xlsx";
}

return "";
}

Expand Down

0 comments on commit dbf0bca

Please sign in to comment.