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

Merge in RED/persistence-service from RED-6444 to master

* commit '3f65a7ff002ffe2d37cb1d0ab9cf3c4632de18a2':
  RED-6444: Download with onetime token uses tenant from request parameter
This commit is contained in:
Dominique Eiflaender 2023-03-21 13:12:18 +01:00 committed by Timo Bejan
commit 112a27561b
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);
}