๐Ÿ“๐Ÿ–ผ๏ธ๐Ÿน A small thing where I can upload a file and get a link back. https://media.strawmelonjuice.com/
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Supply the byte size too... because well


Signed-off-by: MLC Bloeiman <mar@strawmelonjuice.com>

+8 -7
+6 -7
server-rs/src/app/files.rs
··· 61 61 &self, 62 62 user: User, 63 63 ) -> std::result::Result<Vec<File>, DbError> { 64 - 65 64 if user.is_admin { 66 65 let files = query!( 67 66 "SELECT id as 'id: Uuid', filename, username FROM file_mapping LEFT JOIN users ON users.uid = file_mapping.owner_uid" ··· 113 112 114 113 let file_metadata = fs::metadata(file_on_fs); 115 114 116 - let size_mb = if let Ok(file_metadata) = file_metadata { 117 - let bytes = file_metadata.len() as f64; 118 - // I divided by 1_000_000.0 in original impl I think. 119 - bytes / 1048576.0 115 + let size = if let Ok(file_metadata) = file_metadata { 116 + file_metadata.len() 120 117 } else { 121 118 // If we couldn't get the metadata just return 0. 122 - 0.0 119 + 0 123 120 }; 124 121 125 122 File { 126 123 id: file.id, 127 124 filename: file.filename.clone(), 128 125 owner: Some(user.username.clone()), 129 - size_mb, 126 + // I divided by 1_000_000.0 in original impl I think. 127 + size_mb: size as f64 / 1048576.0, 128 + size, 130 129 } 131 130 }) 132 131 .collect();
+2
server-rs/src/routes/api.rs
··· 237 237 // these are in mb's as initially I was thinking of setting 1mb as minimum... I am so dumb. 238 238 // However, because they are a floating point number instead of an int nowadays, they can do much lower too. 239 239 pub(crate) size_mb: f64, 240 + // doing it properly.. 241 + pub(crate) size: u64, 240 242 } 241 243 242 244 #[post("/user/fetch", data = "<single_identify>")]