@@ -17,6 +17,8 @@ import ru.soune.nocopy.repository.UserRepository;
|
||||
import ru.soune.nocopy.service.file.CheckCounterService;
|
||||
import ru.soune.nocopy.service.file.FileStorageService;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -71,10 +73,14 @@ public class FileController {
|
||||
throw new RuntimeException("File is not protected");
|
||||
}
|
||||
|
||||
String fileName = fileEntity.getOriginalFileName();
|
||||
String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8)
|
||||
.replace("+", "%20");
|
||||
|
||||
return ResponseEntity.ok()
|
||||
.contentType(new MediaType(fileEntity.getMimeType(), fileEntity.getFileExtension()))
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION,
|
||||
"inline; filename=\"" + fileEntity.getOriginalFileName() + "\"")
|
||||
"inline; filename*=UTF-8''" + encodedFileName)
|
||||
.body(resource);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user