/// <summary> /// Check whether the object key exists and hash is equivalent. If these are the same we will skip the upload. /// </summary> /// <param name="client"></param> /// <param name="request"></param> /// <returns></returns> private async Task <bool> ShouldUpload(AmazonS3Client client, PutObjectRequest request) { //This isn't ideal, however the AWS SDK doesn't really provide any means to check the existence of an object. try { if (!md5HashSupported) { return(true); } var metadataResponse = await client.GetObjectMetadataAsync(request.BucketName, request.Key); return(!metadataResponse.GetEtag().IsSameAsRequestMd5Digest(request) || !request.HasSameMetadata(metadataResponse)); } catch (AmazonServiceException exception) { if (exception.StatusCode == HttpStatusCode.NotFound) { return(true); } throw; } }