30 QgsWebDAVExternalStorageStoreTask::QgsWebDAVExternalStorageStoreTask(
const QUrl &url,
const QString &filePath,
const QString &authCfg )
31 :
QgsTask( tr(
"Storing %1" ).arg( QFileInfo( filePath ).baseName() ) )
33 , mFilePath( filePath )
39 bool QgsWebDAVExternalStorageStoreTask::run()
44 QNetworkRequest req( mUrl );
47 QFile *f =
new QFile( mFilePath );
48 f->open( QIODevice::ReadOnly );
52 if ( !isCanceled() && bytesTotal > 0 )
54 const int progress = ( bytesReceived * 100 ) / bytesTotal;
55 setProgress( progress );
69 void QgsWebDAVExternalStorageStoreTask::cancel()
75 QString QgsWebDAVExternalStorageStoreTask::errorString()
const
80 QgsWebDAVExternalStorageStoredContent::QgsWebDAVExternalStorageStoredContent(
const QString &filePath,
const QString &url,
const QString &authcfg )
82 QString storageUrl = url;
83 if ( storageUrl.endsWith(
"/" ) )
84 storageUrl.append( QFileInfo( filePath ).fileName() );
86 mUploadTask =
new QgsWebDAVExternalStorageStoreTask( storageUrl, filePath, authcfg );
97 reportError( mUploadTask->errorString() );
102 emit progressChanged( progress );
106 void QgsWebDAVExternalStorageStoredContent::store()
113 void QgsWebDAVExternalStorageStoredContent::cancel()
125 mUploadTask->cancel();
128 QString QgsWebDAVExternalStorageStoredContent::url()
const
134 QgsWebDAVExternalStorageFetchedContent::QgsWebDAVExternalStorageFetchedContent(
QgsFetchedContent *fetchedContent )
135 : mFetchedContent( fetchedContent )
141 reportError( errorMsg );
145 void QgsWebDAVExternalStorageFetchedContent::fetch()
147 if ( !mFetchedContent )
151 mFetchedContent->download();
161 QString QgsWebDAVExternalStorageFetchedContent::filePath()
const
163 return mFetchedContent ? mFetchedContent->filePath() : QString();
166 void QgsWebDAVExternalStorageFetchedContent::onFetched()
168 if ( !mFetchedContent )
178 void QgsWebDAVExternalStorageFetchedContent::cancel()
180 mFetchedContent->cancel();
183 QString QgsWebDAVExternalStorage::type()
const
185 return QStringLiteral(
"WebDAV" );
188 QString QgsWebDAVExternalStorage::displayName()
const
190 return QObject::tr(
"WebDAV Storage" );
195 return new QgsWebDAVExternalStorageStoredContent( filePath, url, authcfg );
202 return new QgsWebDAVExternalStorageFetchedContent( fetchedContent );