Skip to content
Snippets Groups Projects
Verified Commit ab3dbb6a authored by Volkor Barbarian Warrior's avatar Volkor Barbarian Warrior
Browse files

forgot one

parent 596f3616
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ use std::{
path::{Path, PathBuf},
time::SystemTime,
};
use tracing::{debug, error, info};
use tracing::{debug, error, info, trace};
use super::guess_ip;
use crate::{
......@@ -25,7 +25,7 @@ pub async fn upload(req: &mut Request, res: &mut Response) {
let remote_addr = &req.remote_addr().clone();
// Get the host header for nicely setting up the response.
let host = headers[HOST].to_str().unwrap_or("localhost:8282");
tracing::debug!("upload(req): {:?}", req);
debug!("upload(req): {:?}", req);
// Check if the request was done in https or not by seeing if "x-forwarded-proto" exists.
let mut https: String = "http".to_string();
......@@ -61,12 +61,12 @@ pub async fn upload(req: &mut Request, res: &mut Response) {
.read_to_end(&mut buffer)
.expect("couldn't read mimetype buffer");
tracing::trace!("read bytes for mime parsing: {:x?}", buffer);
trace!("read bytes for mime parsing: {:x?}", buffer);
// Guess the mimetype
let mimetype: &str = &detect_mime_type(&buffer).unwrap_or("text/plain".to_string());
tracing::debug!("upload(mimetype): {:?}", mimetype);
debug!("upload(mimetype): {:?}", mimetype);
// Check if the mimetype is banned, and render the error pages.
if is_mimetype_banned(mimetype).await {
......@@ -93,17 +93,16 @@ pub async fn upload(req: &mut Request, res: &mut Response) {
// Generate the admin key.
let adminkey = engine::generate_adminkey(sqlconn).await;
tracing::debug!("upload(filename, adminkey): {:?}, {:?}", filename, adminkey);
debug!("upload(filename, adminkey): {:?}, {:?}", filename, adminkey);
// Set Destination
let dest: PathBuf = PathBuf::from("files/").join(&filename);
// Copy the file
if let Err(e) = std::fs::copy(file.path(), Path::new(&dest)) {
tracing::error!(
error!(
"There was a problem uploading file: {:?}, error: {}",
dest,
e
dest, e
);
// If web is true, render html, otherwise json.
if upload_by_web {
......@@ -169,7 +168,7 @@ pub async fn upload(req: &mut Request, res: &mut Response) {
error!("File upload error: {:?}", e);
}
info!("File uploaded to {:?}", dest);
info!("[{}]File uploaded to {:?}", &host, dest);
let fileurl = format!(
"{}://{}/{}",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment