An error occurred while fetching merge requests data.
Commit cd8a5094 authored by 0Tyler's avatar 0Tyler

defaultData

parent de22d29d
No preview for this file type
No preview for this file type
This diff is collapsed.
......@@ -50,7 +50,7 @@ jar {
enabled = true
}
bootJar {
enabled = false
enabled = true
classifier = 'boot'
manifest {
attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.cloud.CloudApplication'
......
......@@ -5,6 +5,7 @@ import edu.prlab.tyler.iotgateway.cloud.services.DocumentService;
import edu.prlab.tyler.iotgateway.cloud.services.PrivacyPolicyReportService;
import edu.prlab.tyler.iotgateway.cloud.util.CodeTools;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......@@ -35,15 +36,14 @@ public class DocumentController {
//透過裝置ID取得檔案
@GetMapping("/{udn}")
public ResponseEntity<ByteArrayResource> findFile(@PathVariable String udn) {
public ResponseEntity<Resource> findFile(@PathVariable String udn) {
return privacyPolicyReportService.readByDevice(udn)
.map(privacyReport -> privacyReport.getDocument().getId())
.flatMap(id -> documentService.readFile(id))
.map(document -> ResponseEntity.ok()
.contentType(MediaType.parseMediaType(document.getFileType()))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename* = UTF-8''" + CodeTools.encode(document.getFileName()))
.body(new ByteArrayResource(document.getBytes())))
.body((Resource) new ByteArrayResource(document.getBytes())))
.orElseGet(() -> ResponseEntity.noContent().build());
}
}
File added
File added
No preview for this file type
......@@ -46,7 +46,7 @@ jar {
enabled = true
}
bootJar {
enabled = false
enabled = true
classifier = 'boot'
manifest {
attributes 'Start-Class': 'edu.prlab.tyler.iotgateway.gateway.GatewayApplication'
......
......@@ -2,7 +2,6 @@ package edu.prlab.tyler.iotgateway.gateway.controllers;
import edu.prlab.tyler.iotgateway.cloud.pojo.device.Device;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyChoice;
import edu.prlab.tyler.iotgateway.cloud.pojo.privacy.PrivacyPolicyReport;
import edu.prlab.tyler.iotgateway.gateway.model.PrivacyChoiceResponse;
import edu.prlab.tyler.iotgateway.gateway.model.PrivacyPolicyReportResponse;
import edu.prlab.tyler.iotgateway.gateway.services.DeviceService;
......
......@@ -19,8 +19,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@Service
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment