Last active
August 29, 2015 14:04
-
-
Save codeguru42/dc6aadaa6a8ecce6469c to your computer and use it in GitHub Desktop.
postVideoData
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(method = RequestMethod.POST, value = "/video/{id}/data") | |
public Video postVideoData(@PathVariable("id") int videoId, | |
@RequestParam("data") MultipartFile videoData) throws IOException { | |
Video video = videos.get(videoId); | |
InputStream in = videoData.getInputStream(); | |
manager.saveVideoData(video, in); | |
return video; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Multipart | |
@POST(VIDEO_DATA_PATH) | |
public VideoStatus setVideoData(@Path(ID_PARAMETER) long id, @Part(DATA_PARAMETER) TypedFile videoData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testAddVideoData() throws Exception { | |
Video received = videoSvc.addVideo(video); | |
VideoStatus status = videoSvc.setVideoData(received.getId(), | |
new TypedFile(received.getContentType(), testVideoData)); | |
assertEquals(VideoState.READY, status.getState()); | |
Response response = videoSvc.getData(received.getId()); | |
assertEquals(200, response.getStatus()); | |
InputStream videoData = response.getBody().in(); | |
byte[] originalFile = IOUtils.toByteArray(new FileInputStream(testVideoData)); | |
byte[] retrievedFile = IOUtils.toByteArray(videoData); | |
assertTrue(Arrays.equals(originalFile, retrievedFile)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment