mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 01:36:18 +00:00
Closes #140: video file support
This commit is contained in:
@@ -20,12 +20,17 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center" ng-if="$stateParams.fileId">
|
||||
<div class="text-center" style="position: relative;" ng-if="$stateParams.fileId">
|
||||
<img ng-src="../api/file/{{ $stateParams.fileId }}/data?size=web"
|
||||
ng-init="error = false"
|
||||
img-error="error = true"
|
||||
ng-show="!error" />
|
||||
<a href class="video-overlay" ng-if="file.mimetype.substring(0, 6) == 'video/'"
|
||||
ng-init="videoPlayer = false" ng-click="videoPlayer = true">
|
||||
<span class="glyphicon glyphicon-play-circle" ng-if="!videoPlayer"></span>
|
||||
<video ng-if="videoPlayer" autoplay="autoplay" loop="loop"
|
||||
controls="controls" ng-src="../api/file/{{ $stateParams.fileId }}/data"></video>
|
||||
</a>
|
||||
<p class="well-lg" ng-show="error">
|
||||
<span class="glyphicon glyphicon-warning-sign"></span>
|
||||
{{ 'file.view.not_found' | translate }}
|
||||
|
||||
@@ -392,6 +392,33 @@ input[readonly].share-link {
|
||||
}
|
||||
}
|
||||
|
||||
// Video player
|
||||
.video-overlay {
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
font-size: 500%;
|
||||
color: #242424;
|
||||
|
||||
.glyphicon {
|
||||
text-shadow: 0 0 20px #fff;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #444;
|
||||
}
|
||||
|
||||
video {
|
||||
cursor: default;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical alignment
|
||||
.vertical-center {
|
||||
min-height: 100vh;
|
||||
|
||||
@@ -603,6 +603,65 @@ public class TestDocumentResource extends BaseJerseyTest {
|
||||
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test video extraction.
|
||||
*
|
||||
* @throws Exception e
|
||||
*/
|
||||
@Test
|
||||
public void testVideoExtraction() throws Exception {
|
||||
// Login document_video
|
||||
clientUtil.createUser("document_video");
|
||||
String documentPlainToken = clientUtil.login("document_video");
|
||||
|
||||
// Create a document
|
||||
long create1Date = new Date().getTime();
|
||||
JsonObject json = target().path("/document").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentPlainToken)
|
||||
.put(Entity.form(new Form()
|
||||
.param("title", "My super title document 1")
|
||||
.param("description", "My super description for document 1")
|
||||
.param("language", "eng")
|
||||
.param("create_date", Long.toString(create1Date))), JsonObject.class);
|
||||
String document1Id = json.getString("id");
|
||||
Assert.assertNotNull(document1Id);
|
||||
|
||||
// Add a video file
|
||||
String file1Id;
|
||||
try (InputStream is = Resources.getResource("file/video.webm").openStream()) {
|
||||
StreamDataBodyPart streamDataBodyPart = new StreamDataBodyPart("file", is, "video.webm");
|
||||
try (FormDataMultiPart multiPart = new FormDataMultiPart()) {
|
||||
json = target()
|
||||
.register(MultiPartFeature.class)
|
||||
.path("/file").request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentPlainToken)
|
||||
.put(Entity.entity(multiPart.field("id", document1Id).bodyPart(streamDataBodyPart),
|
||||
MediaType.MULTIPART_FORM_DATA_TYPE), JsonObject.class);
|
||||
file1Id = json.getString("id");
|
||||
Assert.assertNotNull(file1Id);
|
||||
}
|
||||
}
|
||||
|
||||
// Search documents by query in full content
|
||||
json = target().path("/document/list")
|
||||
.queryParam("search", "full:vp9")
|
||||
.request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentPlainToken)
|
||||
.get(JsonObject.class);
|
||||
Assert.assertTrue(json.getJsonArray("documents").size() == 1);
|
||||
|
||||
// Get the file thumbnail data
|
||||
Response response = target().path("/file/" + file1Id + "/data")
|
||||
.queryParam("size", "thumb")
|
||||
.request()
|
||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, documentPlainToken)
|
||||
.get();
|
||||
InputStream is = (InputStream) response.getEntity();
|
||||
byte[] fileBytes = ByteStreams.toByteArray(is);
|
||||
Assert.assertTrue(fileBytes.length > 0); // Images rendered from PDF differ in size from OS to OS due to font issues
|
||||
Assert.assertEquals(MimeType.IMAGE_JPEG, MimeTypeUtil.guessMimeType(fileBytes, null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test EML import.
|
||||
*
|
||||
|
||||
BIN
docs-web/src/test/resources/file/video.webm
Normal file
BIN
docs-web/src/test/resources/file/video.webm
Normal file
Binary file not shown.
Reference in New Issue
Block a user