This commit is contained in:
@@ -10,7 +10,6 @@ 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;
|
||||||
@@ -43,10 +42,10 @@ import ru.soune.nocopy.service.file.CheckCounterService;
|
|||||||
import ru.soune.nocopy.service.file.ProtectionsLimitService;
|
import ru.soune.nocopy.service.file.ProtectionsLimitService;
|
||||||
import ru.soune.nocopy.service.file.cloud.CloudStorageService;
|
import ru.soune.nocopy.service.file.cloud.CloudStorageService;
|
||||||
import ru.soune.nocopy.service.register.AuthService;
|
import ru.soune.nocopy.service.register.AuthService;
|
||||||
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.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -608,13 +607,13 @@ public class ApiController {
|
|||||||
dockViewService.createDockView(viewerRequest, userId);
|
dockViewService.createDockView(viewerRequest, userId);
|
||||||
|
|
||||||
String filename = entityResponse.getFileName();
|
String filename = entityResponse.getFileName();
|
||||||
ContentDisposition contentDisposition = ContentDisposition.builder("attachment")
|
String encodedFilename = URLEncoder.encode(filename, StandardCharsets.UTF_8)
|
||||||
.filename(filename, StandardCharsets.UTF_8)
|
.replace("+", "%20");
|
||||||
.build();
|
|
||||||
|
|
||||||
return ResponseEntity.ok()
|
return ResponseEntity.ok()
|
||||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||||
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString())
|
.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||||
|
"attachment; filename*=UTF-8''" + encodedFilename)
|
||||||
.body(bytes);
|
.body(bytes);
|
||||||
} catch (FileEntityNotFoundException e) {
|
} catch (FileEntityNotFoundException e) {
|
||||||
Map<String, Object> errorData = new HashMap<>();
|
Map<String, Object> errorData = new HashMap<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user