RED-6444: Download with onetime token uses tenant from request parameter

This commit is contained in:
deiflaender 2023-03-21 12:38:08 +01:00
parent d392c1dae7
commit 3f65a7ff00
2 changed files with 8 additions and 2 deletions

View File

@ -262,13 +262,18 @@ public class DownloadController implements DownloadResource {
@Override
public ResponseEntity<FileSystemResource> downloadFileUsingOTT(@PathVariable(OTT) String oneTimeToken,
@RequestParam(value = "inline", required = false, defaultValue = FALSE) boolean inline) {
@RequestParam(value = "inline", required = false, defaultValue = FALSE) boolean inline,
@RequestParam(value = "tenantId") String tenantId) {
TenantContext.setTenantId(tenantId);
log.debug("downloadFileUsingOTT '{}'", oneTimeToken);
var token = oneTimeTokenDownloadService.getToken(oneTimeToken);
var downloadStatus = getDownloadStatus(token.getStorageId(), token.getUserId());
var fileDownloadStream = getFileForDownload(token.getStorageId(), token.getUserId());
TenantContext.clear();
return getResponseEntity(inline, fileDownloadStream, downloadStatus.getFilename(), MediaType.parseMediaType("application/zip"));
}

View File

@ -84,6 +84,7 @@ public interface DownloadResource {
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "Download with this Id is no longer available"), @ApiResponse(responseCode = "400", description = "OTT is not valid")})
@GetMapping(value = REST_PATH + OTT_PATH + OTT_PATH_VARIABLE)
ResponseEntity<FileSystemResource> downloadFileUsingOTT(@PathVariable(OTT) String oneTimeToken,
@RequestParam(value = "inline", required = false, defaultValue = FALSE) boolean inline);
@RequestParam(value = "inline", required = false, defaultValue = FALSE) boolean inline,
@RequestParam(value = "tenantId") String tenantId);
}