/
Shymer123
/
LumenServer
Обзор
Документация
Войти
/
Shymer123
/
LumenServer
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Server/SourceFiles/Services/FileService.h
55 строк
2 KB
Shymer123
Initial commit: LumenServer
20 июн 2026, 12:43
20 июн 2026, 12:43
173f14c
Код
Авторство
О чём код?
#ifndef FILESERVICE_H #define FILESERVICE_H #include <string> #include <vector> #include <mutex> #include <unordered_map> #include "Data/Models/FileTransferInfo.h" #include "Storage/Db/Repositories/FileRepository.h" namespace Services { class FileService { public: struct FileOperationResult { bool success = false; std::string errorMessage; std::string fileId; }; explicit FileService(Storage::Db::Repositories::FileRepository& fileRepo); void startUploadSession(const Data::Models::FileAttachment& baseInfo, const std::string& checksum); bool uploadChunk(const std::string& fileId, int64_t offset, size_t length, const std::vector<std::byte>& data); FileOperationResult completeUpload(const std::string& fileId); bool cancelUpload(const std::string& fileId); Data::Models::FileTransferInfo startDownloadSession(const std::string& fileId); std::vector<std::byte> downloadChunk(const std::string& fileId, size_t offset, size_t length); Data::Models::FileAttachment getFileInfo(const std::string& fileId) const; Data::Models::FileTransferInfo getUploadStatus(const std::string& fileId); bool fileExists(const std::string& fileId) const; bool saveFileMeta(const Data::Models::FileAttachment& model, const std::string& messageId, const std::string& storagePath); std::vector<Data::Models::FileAttachment> getFilesByMessageId(const std::string& messageId); bool deleteFile(const std::string& fileId); std::string getFilePath(const std::string& fileId) const; private: Storage::Db::Repositories::FileRepository& m_fileRepo; std::mutex m_mutex; static constexpr size_t CHUNK_SIZE = 64 * 1024; std::unordered_map<std::string, Data::Models::FileTransferInfo> m_uploadFiles; }; } // namespace Services #endif // FILESERVICE_H