Skip to content

Commit 4da266b

Browse files
committed
add if match statement to download
1 parent bf3c4a8 commit 4da266b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Diff for: src/aws-cpp-sdk-transfer/include/aws/transfer/TransferHandle.h

+7
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ namespace Aws
297297
const Aws::String GetVersionId() const { std::lock_guard<std::mutex> locker(m_getterSetterLock); return m_versionId; }
298298
void SetVersionId(const Aws::String& versionId) { std::lock_guard<std::mutex> locker(m_getterSetterLock); m_versionId = versionId; }
299299

300+
/**
301+
* (Download only) ETAG of the object to retrieve.
302+
*/
303+
const Aws::String GetEtag() const { std::lock_guard<std::mutex> locker(m_getterSetterLock); return m_etag; }
304+
void SetEtag(const Aws::String& etag) { std::lock_guard<std::mutex> locker(m_getterSetterLock); m_etag = etag; }
305+
300306
/**
301307
* Upload or Download?
302308
*/
@@ -405,6 +411,7 @@ namespace Aws
405411
Aws::String m_fileName;
406412
Aws::String m_contentType;
407413
Aws::String m_versionId;
414+
Aws::String m_etag;
408415
Aws::Map<Aws::String, Aws::String> m_metadata;
409416
TransferStatus m_status;
410417
Aws::Client::AWSError<Aws::S3::S3Errors> m_lastError;

Diff for: src/aws-cpp-sdk-transfer/source/transfer/TransferManager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ namespace Aws
931931
handle->SetBytesTotalSize(downloadSize);
932932
handle->SetContentType(headObjectOutcome.GetResult().GetContentType());
933933
handle->SetMetadata(headObjectOutcome.GetResult().GetMetadata());
934+
handle->SetEtag(headObjectOutcome.GetResult().GetETag());
934935
/* When bucket versioning is suspended, head object will return "null" for unversioned object.
935936
* Send following GetObject with "null" as versionId will result in 403 access denied error if your IAM role or policy
936937
* doesn't have GetObjectVersion permission.
@@ -1012,6 +1013,7 @@ namespace Aws
10121013
getObjectRangeRequest.WithKey(handle->GetKey());
10131014
getObjectRangeRequest.SetRange(FormatRangeSpecifier(rangeStart, rangeEnd));
10141015
getObjectRangeRequest.SetResponseStreamFactory(responseStreamFunction);
1016+
getObjectRangeRequest.SetIfMatch(handle->GetEtag());
10151017
if(handle->GetVersionId().size() > 0)
10161018
{
10171019
getObjectRangeRequest.SetVersionId(handle->GetVersionId());

0 commit comments

Comments
 (0)