Minor Changes

This commit is contained in:
omenem 2020-04-13 15:44:47 +02:00
parent 8d0ec2ea63
commit 2b93ffa07b
2 changed files with 13 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.core.io.FileSystemResource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -37,6 +38,12 @@ public class SecurityCameraController {
return securityCameraService.findById(id).orElseThrow(NotFoundException::new);
}
@GetMapping("/{id}/video")
public FileSystemResource getVideo(@PathVariable("id") long id) throws NotFoundException {
SecurityCamera s = findById(id);
return s.getSurveillanceVideo();
}
private SecurityCamera save(SecurityCamera newSC, SecurityCameraSaveRequest sc) {
newSC.setName(sc.getName());
newSC.setRoomId(sc.getRoomId());

View file

@ -1,5 +1,6 @@
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
import java.io.File;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
@ -21,8 +22,12 @@ public class SecurityCamera extends Switchable {
@NotNull
private String path = "backend/media/security_camera_videos/security_camera_1.mp4";
public String getPath() {
return path;
}
public FileSystemResource getSurveillanceVideo() {
return new FileSystemResource(path);
return new FileSystemResource(new File(path));
}
@Override