Skip to content

Commit 66dcd79

Browse files
committed
videos as video
1 parent c227e45 commit 66dcd79

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/simple.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use askama_actix::TemplateToResponse;
2121
use chrono::{Duration, Utc};
2222
use futures::{future::ready, StreamExt, TryStreamExt};
2323
use futures_util::Stream;
24-
use mime_guess::mime::{self, APPLICATION_OCTET_STREAM, IMAGE};
24+
use mime_guess::mime::{self, APPLICATION_OCTET_STREAM, IMAGE, VIDEO};
2525
use rand::distributions::{Alphanumeric, DistString};
2626
use serde::Deserialize;
2727
use syntect::{html::ClassedHTMLGenerator, parsing::SyntaxSet, util::LinesWithEndings};
@@ -203,6 +203,24 @@ async fn get_ext(
203203
}
204204
.to_response()
205205
}
206+
Some(mime) if mime.type_() == VIDEO => {
207+
#[derive(Template)]
208+
#[template(path = "video.html")]
209+
struct Video {
210+
file_name: FileName,
211+
delete_at: Option<DateTime>,
212+
owner: bool,
213+
copy: Option<String>,
214+
}
215+
216+
Video {
217+
file_name,
218+
delete_at,
219+
owner,
220+
copy: None,
221+
}
222+
.to_response()
223+
}
206224
_ if file.len() < 50_000 => {
207225
if let Ok(file) =
208226
String::from_utf8(file.to_vec().await.map_err(ErrorInternalServerError)?)

templates/video.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends "get.html" %}
2+
3+
{% block file %}
4+
<video src="raw/{{ file_name }}" alt="Shared Video" autoplay controls>
5+
{% endblock %}

0 commit comments

Comments
 (0)