dev fix download with cyrrilic symbols
Test Workflow / test (push) Has been cancelled

This commit is contained in:
2026-05-22 14:50:15 +07:00
parent 9afe09ccc5
commit b143b29a78
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault; import org.springframework.data.web.PageableDefault;
import org.springframework.http.ContentDisposition;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -46,6 +47,7 @@ import ru.soune.nocopy.service.user.moderation.UserVerificationService;
import ru.soune.nocopy.util.FileUtil; import ru.soune.nocopy.util.FileUtil;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -605,10 +607,14 @@ public class ApiController {
dockViewService.createDockView(viewerRequest, userId); dockViewService.createDockView(viewerRequest, userId);
String filename = entityResponse.getFileName();
ContentDisposition contentDisposition = ContentDisposition.attachment()
.filename(filename, StandardCharsets.UTF_8)
.build();
return ResponseEntity.ok() return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_OCTET_STREAM) .contentType(MediaType.APPLICATION_OCTET_STREAM)
.header(HttpHeaders.CONTENT_DISPOSITION, .header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString())
"attachment; filename=\"" + entityResponse.getFileName() + "\"")
.body(bytes); .body(bytes);
} catch (FileEntityNotFoundException e) { } catch (FileEntityNotFoundException e) {
Map<String, Object> errorData = new HashMap<>(); Map<String, Object> errorData = new HashMap<>();