diff --git a/backend/src/controllers/auth/auth_2fa.cpp b/backend/src/controllers/auth/auth_2fa.cpp index 02123c8..8513b75 100644 --- a/backend/src/controllers/auth/auth_2fa.cpp +++ b/backend/src/controllers/auth/auth_2fa.cpp @@ -57,7 +57,7 @@ namespace api { std::string code = create_totp_qrcode(user, b32_secret); cbk(dto::Responses::get_tfa_setup_res(b32_secret, code)); } - } catch (const std::exception& e) { + } catch (const std::exception&) { cbk(dto::Responses::get_badreq_res("Validation error")); } } diff --git a/backend/src/controllers/controllers.h b/backend/src/controllers/controllers.h index 890b06d..d91a9ed 100644 --- a/backend/src/controllers/controllers.h +++ b/backend/src/controllers/controllers.h @@ -90,7 +90,6 @@ public: METHOD_ADD(fs::download, "/download", drogon::Post, "Login"); METHOD_ADD(fs::download_multi, "/download_multi", drogon::Post, "Login"); METHOD_ADD(fs::download_preview, "/download_preview/{}", drogon::Get, "Login"); - METHOD_ADD(fs::download_base64, "/download_base64/{}", drogon::Get, "Login"); METHOD_ADD(fs::get_type, "/get_type/{}", drogon::Get, "Login"); METHOD_LIST_END @@ -124,7 +123,6 @@ public: void download(req_type, cbk_type); void download_multi(req_type, cbk_type); void download_preview(req_type, cbk_type, uint64_t node); - void download_base64(req_type, cbk_type, uint64_t node); void get_type(req_type, cbk_type, uint64_t node); }; diff --git a/backend/src/controllers/fs.cpp b/backend/src/controllers/fs.cpp index f16bb5b..24ae16a 100644 --- a/backend/src/controllers/fs.cpp +++ b/backend/src/controllers/fs.cpp @@ -554,28 +554,6 @@ namespace api { cbk(dto::Responses::get_download_base64_res("data:image/png;base64," + Botan::base64_encode(image))); } - void fs::download_base64(req_type req, cbk_type cbk, uint64_t node) { - db::User user = dto::get_user(req); - - auto inode = get_node_and_validate(user, node); - if (!inode.has_value()) - return cbk(dto::Responses::get_badreq_res("Unknown node")); - - - std::filesystem::path p("./files"), name(inode->getValueOfName()); - p /= std::to_string(inode->getValueOfId()); - - try { - std::string mime = mime_type_map.at(name.extension().string()); - std::ifstream file(p, std::ios::in | std::ios::binary); - std::vector content((std::istreambuf_iterator(file)), std::istreambuf_iterator()); - - cbk(dto::Responses::get_download_base64_res("data:" + mime + ";base64," + Botan::base64_encode(content))); - } catch (const std::exception&) { - cbk(dto::Responses::get_badreq_res("Invalid file type")); - } - } - void fs::get_type(req_type req, cbk_type cbk, uint64_t node){ db::User user = dto::get_user(req); diff --git a/backend/src/dto/dto.h b/backend/src/dto/dto.h index d605993..b4d6348 100644 --- a/backend/src/dto/dto.h +++ b/backend/src/dto/dto.h @@ -22,9 +22,9 @@ namespace dto { namespace Responses { struct GetUsersEntry { - GetUsersEntry(int id, bool gitlab, bool tfa, std::string name, db::UserRole role) + GetUsersEntry(uint64_t id, bool gitlab, bool tfa, std::string name, db::UserRole role) : id(id), gitlab(gitlab), tfa(tfa), name(std::move(name)), role(role) {} - int id; + uint64_t id; bool gitlab, tfa; std::string name; db::UserRole role; diff --git a/frontend/src/api/fs.ts b/frontend/src/api/fs.ts index 6f3ffac..83f6b82 100644 --- a/frontend/src/api/fs.ts +++ b/frontend/src/api/fs.ts @@ -73,12 +73,6 @@ export const download_preview = ( ): Promise => get_token(`/api/fs/download_preview/${node}`, token); -export const download_base64 = ( - token: string, - node: number -): Promise => - get_token(`/api/fs/download_base64/${node}`, token); - export const get_type = ( token: string, node: number diff --git a/frontend/src/components/FileViewer/AudioVideoDownload.tsx b/frontend/src/components/FileViewer/BlobDownload.tsx similarity index 76% rename from frontend/src/components/FileViewer/AudioVideoDownload.tsx rename to frontend/src/components/FileViewer/BlobDownload.tsx index ddd30c1..9088599 100644 --- a/frontend/src/components/FileViewer/AudioVideoDownload.tsx +++ b/frontend/src/components/FileViewer/BlobDownload.tsx @@ -1,22 +1,24 @@ import { ref } from 'vue'; import { NProgress } from 'naive-ui'; import filesize from 'filesize'; -import { Music, Video } from '@vicons/carbon'; +import { Music, Video, Image } from '@vicons/carbon'; import type { DialogApiInjection } from 'naive-ui/es/dialog/src/DialogProvider'; -export default function createAudioVideoDialog( +export default function createBlobDialog( dialog: DialogApiInjection, + audio: boolean, video: boolean ) { const progress = ref(0); const total = ref(1); const percentage = ref(0); const dia = dialog.create({ - title: video ? 'Loading video...' : 'Loading audio...', + title: + 'Loading ' + (video ? 'video' : audio ? 'audio' : 'image') + '...', closable: false, closeOnEsc: false, maskClosable: false, - icon: () => (video ?