Skip to content

Commit

Permalink
Merge pull request IQSS#9768 from stevenferey/9429-redetect-file-type…
Browse files Browse the repository at this point in the history
…-api-with-ingested-files

exclusion of ingested files during mimetype redetection
  • Loading branch information
kcondon authored Sep 15, 2023
2 parents 92404af + 1fb3722 commit 4e1bc5b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/api/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ public Response reingest(@Context ContainerRequestContext crc, @PathParam("id")
public Response redetectDatafile(@Context ContainerRequestContext crc, @PathParam("id") String id, @QueryParam("dryRun") boolean dryRun) {
try {
DataFile dataFileIn = findDataFileOrDie(id);
// Ingested Files have mimetype = text/tab-separated-values
// No need to redetect
if (dataFileIn.isTabularData()) {
return error(Response.Status.BAD_REQUEST, "The file is an ingested tabular file.");
}
String originalContentType = dataFileIn.getContentType();
DataFile dataFileOut = execCommand(new RedetectFileTypeCommand(createDataverseRequest(getRequestUser(crc)), dataFileIn, dryRun));
NullSafeJsonBuilder result = NullSafeJsonBuilder.jsonObjectBuilder()
Expand Down

0 comments on commit 4e1bc5b

Please sign in to comment.