Example #1
0
            internal Object Execute()
            {
                _mediaUpload.Upload();
                CheckFinalProgress();
                var result = _mediaUpload.ResponseBody;
                var hash   = _crc == null ? result.Crc32c : Convert.ToBase64String(_crc.GetHash());

                if (hash != result.Crc32c)
                {
                    AggregateException additionalFailures = null;
                    try
                    {
                        _validationFailureAction?.Invoke(result);
                    }
                    catch (Exception e)
                    {
                        additionalFailures = new AggregateException(e);
                    }
                    throw new UploadValidationException(hash, result, additionalFailures);
                }
                return(result);
            }
Example #2
0
        protected override void OnDownloadCompleted()
        {
            base.OnDownloadCompleted();

            if (crc32cHashBase64 != null)
            {
                string actualHash = Convert.ToBase64String(hasher.GetHash());
                if (actualHash != crc32cHashBase64)
                {
                    throw new IOException($"Incorrect hash: expected '{crc32cHashBase64}' (base64), was '{actualHash}' (base64)");
                }
            }
        }