Skip to content

Commit

Permalink
videos as video
Browse files Browse the repository at this point in the history
  • Loading branch information
ModProg committed Sep 9, 2024
1 parent c227e45 commit 66dcd79
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use askama_actix::TemplateToResponse;
use chrono::{Duration, Utc};
use futures::{future::ready, StreamExt, TryStreamExt};
use futures_util::Stream;
use mime_guess::mime::{self, APPLICATION_OCTET_STREAM, IMAGE};
use mime_guess::mime::{self, APPLICATION_OCTET_STREAM, IMAGE, VIDEO};
use rand::distributions::{Alphanumeric, DistString};
use serde::Deserialize;
use syntect::{html::ClassedHTMLGenerator, parsing::SyntaxSet, util::LinesWithEndings};
Expand Down Expand Up @@ -203,6 +203,24 @@ async fn get_ext(
}
.to_response()
}
Some(mime) if mime.type_() == VIDEO => {
#[derive(Template)]
#[template(path = "video.html")]
struct Video {
file_name: FileName,
delete_at: Option<DateTime>,
owner: bool,
copy: Option<String>,
}

Video {
file_name,
delete_at,
owner,
copy: None,
}
.to_response()
}
_ if file.len() < 50_000 => {
if let Ok(file) =
String::from_utf8(file.to_vec().await.map_err(ErrorInternalServerError)?)
Expand Down
5 changes: 5 additions & 0 deletions templates/video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% extends "get.html" %}

{% block file %}
<video src="raw/{{ file_name }}" alt="Shared Video" autoplay controls>
{% endblock %}

0 comments on commit 66dcd79

Please sign in to comment.