感谢the last advice,现在我们可以按批处理中的哈希值检查S3上传文件的完整性;
string path = Microsoft.ServiceBus.Messaging.SubscriptionClient.FormatDeadLetterPath(topicPath, subscriptionName);
var subscriptionClient = SubscriptionClient.CreateFromConnectionString(connectionString, path);
BrokeredMessage message = subscriptionClient.Receive();
如果我们可以通过“ Etag”返回检测到S3上传成功,那么我们希望批量获取它以进行故障检测。
到目前为止,它仍然不符合我的期望...
:: Get the MD5 Hased Value of local target file
CALL %BAT_DIR%\GET_HASHVALUE_BASE64.bat
:: Upload File to S3 with MD5 Hash Value
aws s3api put-object --bucket %S3_BUCKET% --key %S3_SEND_DIR%/%FILE_NAME% --body %SEND_FILE% --metadata md5chksum=%HashBase64% --content-md5 %HashBase64%
-- Hash was matched between the local and uploaded S3 file, "Etag" was returned
{
"ETag": "\"63df79d4c782a0df2186dda1c601931c\""
}
您可能知道用于在S3上传中进行故障检测的任何更智能的方法,再次感谢您的任何建议。
非常感谢。
仅供参考。也许我们稍后会尝试“ S3选择”,但现在我们正在验证最简单的方法
答案 0 :(得分:0)
感谢Squashman,我们现在可以通过错误代码检测到任何s3上传错误。
由于所有上传错误均返回'255',包括哈希不匹配错误和backet名称错误等,因此到目前为止,我们将其设置为每个阶段,这样我们就可以很容易地了解导致错误的根本原因是
:: S3 Bucket Tag Create
aws s3api put-object --bucket %S3_BUCKET% --key %S3_SEND_DIR%/
:: Captuer Error ==> pre-uploading check. Backet name or anything else can be wrong
if %Errorlevel% neq 0 goto ERR_S3_BACKET
:: GetHash Value (Convert from Hex to Base64)
for /f "usebackq delims=" %%h in (`CertUtil -hashfile "%SEND_FILE%" MD5 ^| find /v ":"`) do set HashHex=%%h
for /f "usebackq delims=" %%h in (`cscript //nologo HexToBase64.vbs %HashHex%`) do set HashBase64=%%h
:: Failuer to get Hash Value
if not defined HashBase64 goto ERR_GET_HASH
:: s3 File Upload and captuer error codes
aws s3api put-object --bucket %S3_BUCKET% --key %S3_SEND_DIR%/%FILE_NAME% --body %SEND_FILE% --metadata md5chksum=%HashBase64% --content-md5 %HashBase64%
if %Errorlevel% neq 0 goto ERR_S3_UPLOAD
如果有人也知道如何获取错误详细信息或更聪明的方法。 附加信息或建议将不胜感激。
非常感谢。