diff --git a/cosclient.cpp b/cosclient.cpp index 6d32c48..e8d01a2 100644 --- a/cosclient.cpp +++ b/cosclient.cpp @@ -144,7 +144,7 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const return true; } -QMap COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader) +preResponse COSClient::headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader) { preRequest request; if(!versionId.isEmpty()) { @@ -163,10 +163,11 @@ QMap COSClient::headObject(const QString &path, const QString & request.customHeaders.insert("If-None-Match", reqHeader.ifNoneMatch); } preResponse response = invokeHeadRequest(path, request); - return response.headers; + + return response; } -bool COSClient::deleteObject(const QString &path, const QString &versionId) +preResponse COSClient::deleteObject(const QString &path, const QString &versionId) { preRequest request; bool haveId=!versionId.isEmpty(); @@ -184,7 +185,7 @@ bool COSClient::deleteObject(const QString &path, const QString &versionId) else if(!haveId && deleteMarker){ qDebug()<<"创建了一个删除标记作为"< metaDatas) @@ -213,6 +214,11 @@ QString COSClient::multiUpload(const QString &path, const QString &localpath, QM return result; } +bool COSClient::isExist(preResponse &response) +{ + return response.statusCode!=404; +} + // 修改后的函数实现 preResponse COSClient::invokeGetFileRequest(const QString& path, const preRequest& request) { @@ -527,6 +533,11 @@ QString COSClient::_getContentMD5(const QByteArray &data) return base64; } +QString COSClient::_getContentCRC64(const QString &path) +{ + +} + QNetworkRequest COSClient::buildGetRequest(const QString &path, const QMap queryParams) { if (!preCheckSession()) diff --git a/cosclient.h b/cosclient.h index 1a5c769..ebea1f9 100644 --- a/cosclient.h +++ b/cosclient.h @@ -70,9 +70,10 @@ class COSClient : public QObject QString completeMultipartUpload(QString path, QString uploadId, QMap partEtagMap); QByteArray getObject(const QString &path,const QString &versionId, QMap &respHeaders); bool save2Local(const QString &path, const QString &localpath,const QString &versionId, QMap &respMetaDatas); - QMap headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader); - bool deleteObject(const QString &path, const QString &versionId); + preResponse headObject(const QString &path, const QString &localpath,const QString &versionId, headHeader &reqHeader); + preResponse deleteObject(const QString &path, const QString &versionId); QString multiUpload(const QString &path, const QString &localpath, QMap metaDatas=QMap()); + bool isExist(preResponse &response); private: QString bucketName; @@ -89,6 +90,7 @@ class COSClient : public QObject bool preCheckSession(); QString _getContentTypeByPath(const QString &path); QString _getContentMD5(const QByteArray &data); + QString _getContentCRC64(const QString &path);//获取本地文件crc64 QNetworkRequest buildGetRequest(const QString& path,const QMap queryParams); QNetworkRequest buildPutRequest(const QString& path,const QMap queryParams, const QByteArray& data); QNetworkRequest buildHeadRequest(const QString& path,const QMap queryParams);