Skip to content

Commit

Permalink
headobject函数
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipper209 committed Jul 9, 2024
1 parent eb6e576 commit b9e48ce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
15 changes: 15 additions & 0 deletions cosclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ 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)
{
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<QString, QString> metaDatas)
{
//判断文件存在且可读
Expand Down
13 changes: 7 additions & 6 deletions cosclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ struct preResponse{
QByteArray data;
QMap<QString,QString> headers;
QMap<QString,QString> getMetaDatas(){
// x-cos-meta-*
QMap<QString,QString> 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<QString,QString> 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;
Expand Down Expand Up @@ -64,6 +64,7 @@ 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);
QString multiUpload(const QString &path, const QString &localpath, QMap<QString,QString> metaDatas=QMap<QString,QString>());

private:
Expand Down

0 comments on commit b9e48ce

Please sign in to comment.