Commit b324da9c authored by Martin Straka's avatar Martin Straka

Fixed saving location for iOS

parent 31b396b5
......@@ -365,10 +365,23 @@ void Files::saveAttachmentsToDisk(const QString &userName, qint64 msgId)
return;
}
QString path = QFileDialog::getExistingDirectory(0,
tr("Select Directory"),
getBasePathBasedOnPlatform(),
QString path = getBasePathBasedOnPlatform();
#if defined Q_OS_IOS
/* There is only one location where files or data can store
* permanently and share with Desktop.
* See: https://developer.apple.com/library/content/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html
*/
path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#else
/* Another platform can select destination for attachment saving. */
path = QFileDialog::getExistingDirectory(0,
tr("Select directory"), path,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
#endif
foreach (const FileDb::FileData &file, filelist) {
QByteArray data = QByteArray::fromBase64(file.content.toUtf8());
......
......@@ -225,14 +225,19 @@ QString writeTemporaryFile(const QString &fileName, const QByteArray &data,
QString writeFileToDir(const QString &basePath, const QString &fileName,
qint64 msgId, const QByteArray &data, bool deleteOnError)
{
Q_UNUSED(msgId);
if (fileName.isEmpty() || basePath.isEmpty()) {
Q_ASSERT(0);
return QString();
}
return writeFile(basePath, fileName, data, deleteOnError);
QString filePath = basePath;
#if defined Q_OS_IOS
filePath = setFilePath(basePath, QString::number(msgId));
#else
Q_UNUSED(msgId);
#endif
return writeFile(filePath, fileName, data, deleteOnError);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment