1
votes

i'm trying to create a php script that auto upload file to bucket in AWS S3, and when i runing the script it give the error message like this :

Warning: S3::putObject(): [RequestTimeTooSkewed] The difference between the request time and the current time is too large. in F:\xampp\htdocs\tst\S3.php on line 377

upload-file.php

$bucket = '--** bucket name **--';
//include the S3 class              
if (!class_exists('S3'))require_once('S3.php');

//AWS access info
if (define('awsAccessKey', 'myAccessKeyFromAWS'));
if (define('awsSecretKey', 'mySecretKeyFromAWS'));

//instantiate the class
$s3 = new S3(awsAccessKey, awsSecretKey);
//here if isset $_FILES
if(isset($_FILES['userfile']) && $_FILES['userfile'] != NULL)
{
  $s3->putObjectFile($_FILES['userfile']['tmp_name'], $bucket , $_FILES['userfile']['name'], S3::ACL_PUBLIC_READ_WRITE)
}
<br><br>
<form action="" method="post" enctype="multipart/form-data">
        <span>Upload file</span>
        &nbsp;&nbsp;
        <input type="file" name="userfile" />

        <input type="submit" value="Upload" />
    </form>



any help i'll be thanks.

2
What does your server think the time is? - Chris
You need to update the time on your server. - Mark B
using local host friends, i'll try the code on godaddy and tell u if error happend again - Alejandro Marbilla
it's work fine with godaddy thank u so much Friends and sorry about language i'm not good in English :) thank u - Alejandro Marbilla

2 Answers

0
votes

The reason for this problem is that Amazon S3 allows only a small time stamp variation of up to 15 minutes between the server and its requesting client.

Synchronization of time between the server and the requesting client is very important to have an access to Amazon S3. To get rid of this problem, you have to adjust the client's timing so that there is a maximum time stamp difference of up to 15 minutes. Also set the standard time and zone for your system, in your case set localhost to UTC time.

0
votes

The reason - see answer of @Nick G

Solution (in OS console):

  1. sudo yum update tzdata
  2. sudo ntpdate -s time.nist.gov