diff --git a/Telegram/SourceFiles/storage/file_upload.cpp b/Telegram/SourceFiles/storage/file_upload.cpp index 64fb8ee64b..e3f30c9ea2 100644 --- a/Telegram/SourceFiles/storage/file_upload.cpp +++ b/Telegram/SourceFiles/storage/file_upload.cpp @@ -19,8 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "history/history.h" #include "core/file_location.h" +#include "core/application.h" #include "core/mime_type.h" #include "main/main_session.h" +#include "storage/storage_account.h" #include "apiwrap.h" namespace Storage { @@ -331,6 +333,20 @@ void Uploader::upload( } if (!file->filepath.isEmpty()) { document->setLocation(Core::FileLocation(file->filepath)); + } else if (!file->content.isEmpty() + && Core::App().canSaveFileWithoutAskingForPath()) { + const auto path = DocumentFileNameForSave(document); + if (!path.isEmpty()) { + auto f = QFile(path); + if (f.open(QIODevice::WriteOnly) + && f.write(file->content) == file->content.size()) { + f.close(); + document->setLocation(Core::FileLocation(path)); + session().local().writeFileLocation( + document->mediaKey(), + Core::FileLocation(path)); + } + } } if (file->type == SendMediaType::ThemeFile) { document->checkWallPaperProperties();