diff --git a/cosclient.cpp b/cosclient.cpp index 4488f3f..aa3df4d 100644 --- a/cosclient.cpp +++ b/cosclient.cpp @@ -144,6 +144,21 @@ bool COSClient::save2Local(const QString &path, const QString &localpath, const return true; } +QMap COSClient::headObject(const QString &path, const QString &localpath, const QString &versionId) +{ + preRequest request; + if(!versionId.isEmpty()) + { + request.customHeaders.insert("versionId", versionId); + } + request.customHeaders.insert("If-Modified-Since", ""); + request.customHeaders.insert("If-Unmodified-Since", ""); + request.customHeaders.insert("If-Match", ""); + request.customHeaders.insert("If-None-Match", ""); + preResponse response = invokeHeadRequest(path, request); + return response.getMetaDatas(); +} + QString COSClient::multiUpload(const QString &path, const QString &localpath, QMap metaDatas) { //判断文件存在且可读 diff --git a/cosclient.h b/cosclient.h index 8481092..c13c2ff 100644 --- a/cosclient.h +++ b/cosclient.h @@ -19,13 +19,13 @@ struct preResponse{ QByteArray data; QMap headers; QMap getMetaDatas(){ - // x-cos-meta-* - QMap metaDatas; - for(auto it=headers.begin();it!=headers.end();it++){ - if(it.key().startsWith("x-cos-meta-")){ - metaDatas[it.key().mid(11)]=it.value(); + // x-cos-meta-* + QMap metaDatas; + for(auto it=headers.begin();it!=headers.end();it++){ + if(it.key().startsWith("x-cos-meta-")){ + metaDatas[it.key().mid(11)]=it.value(); + } } - } return metaDatas; }; int statusCode; @@ -64,6 +64,7 @@ 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); QString multiUpload(const QString &path, const QString &localpath, QMap metaDatas=QMap()); private: