Skip to content

Instantly share code, notes, and snippets.

@codeguru42
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeguru42/dc6aadaa6a8ecce6469c to your computer and use it in GitHub Desktop.
Save codeguru42/dc6aadaa6a8ecce6469c to your computer and use it in GitHub Desktop.
postVideoData
@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;
}
@Multipart
@POST(VIDEO_DATA_PATH)
public VideoStatus setVideoData(@Path(ID_PARAMETER) long id, @Part(DATA_PARAMETER) TypedFile videoData);
@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