來源: https://github.com/aws/aws-sdk-js/issues/399#issuecomment-233057244
試試這個:
AWS.events.on('retry', function(response) {
if (response.error.name === 'RequestTimeTooSkewed') {
console.error('User time is not correct. Handling error!');
console.log('AWS systemClockOffset:', AWS.config.systemClockOffset);
var serverTime = Date.parse(response.httpResponse.headers['date']);
var timeNow = new Date().getTime();
console.log('AWS timestamp:', new Date(serverTime));
console.log('Browser timestamp:', new Date(timeNow));
AWS.config.systemClockOffset = Math.abs(timeNow - serverTime);
response.error.retryable = true;
console.log('Setting systemClockOffset to:', AWS.config.systemClockOffset);
console.log('Retrying uploading to S3 once more...');
}
});
你偵測時鐘多少是關閉的,設置AWS.config.systemClockOffset的差異,並重試
你可以有您的應用程序會在允許上傳之前收集其當地時間並在服務器上進行檢查,如果檢查失敗,則提醒用戶並禁用「上傳」功能 – Houseman