Skip to content

Commit

Permalink
coshead
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipper209 committed Jul 10, 2024
1 parent 22f2db4 commit 62401d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 15 additions & 4 deletions cosclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const
return true;
}

QMap<QString,QString> 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()) {
Expand All @@ -163,10 +163,11 @@ QMap<QString,QString> 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();
Expand All @@ -184,7 +185,7 @@ bool COSClient::deleteObject(const QString &path, const QString &versionId)
else if(!haveId && deleteMarker){
qDebug()<<"创建了一个删除标记作为"<<path<<"的最新版本";
}
return deleteMarker;
return response;
}

QString COSClient::multiUpload(const QString &path, const QString &localpath, QMap<QString, QString> metaDatas)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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<QString, QString> queryParams)
{
if (!preCheckSession())
Expand Down
6 changes: 4 additions & 2 deletions cosclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ class COSClient : public QObject
QString completeMultipartUpload(QString path, QString uploadId, QMap<int, QString> partEtagMap);
QByteArray getObject(const QString &path,const QString &versionId, QMap<QString,QString> &respHeaders);
bool save2Local(const QString &path, const QString &localpath,const QString &versionId, QMap<QString,QString> &respMetaDatas);
QMap<QString,QString> 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<QString,QString> metaDatas=QMap<QString,QString>());
bool isExist(preResponse &response);

private:
QString bucketName;
Expand All @@ -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<QString, QString> queryParams);
QNetworkRequest buildPutRequest(const QString& path,const QMap<QString, QString> queryParams, const QByteArray& data);
QNetworkRequest buildHeadRequest(const QString& path,const QMap<QString, QString> queryParams);
Expand Down

0 comments on commit 62401d1

Please sign in to comment.