使用PHP S3级RequestTimeTooSkewed错误 [英] RequestTimeTooSkewed Error using PHP S3 Class

查看:478
本文介绍了使用PHP S3级RequestTimeTooSkewed错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个PHP项目,所以我真的不知道PHP的。

我所试图做的是一个文件上传到使用PHP S3类中的S3桶。的code示例代码段是工作在昨天,但是当我去开始使用它今天再次合作,几乎是完全一样的code停止工作。

现在我只是得到了putObject函数返回以下错误:

警告:S3 :: putObject():RequestTimeTooSkewed请求时间和当前时间之间的差异过大。在/vagrant/LifeInYourWay/S3.php线222

我读的服务器时可能会造成误差,所以我改变了我的服务器时间美国/纽约,但仍然得到同样的事情。有些地方

PHP的code,我有是:

 如果(class_exists(S3)!)require_once('S3.php');

// AWS访问
如果(定义('awsAccessKey')!)限定('awsAccessKey','******');
如果(定义('awsSecretKey')!)限定('awsSecretKey','******');

$ S3 =新S3(awsAccessKey,awsSecretKey);

$ imageName = $ _FILES ['镜像文件'] ['名称'];
$ imageTempName = $ _FILES ['镜像文件'] ['tmp_name的值'];
$ IMAGELINK = $ _ POST ['IMAGELINK'];

如果(strlen的($ IMAGELINK)|| $ IMAGELINK =='的http://'!){
    //创建一个新的水桶
    $ S3-> putBucket(小部件图像,S3 :: ACL_PUBLIC_READ);

    //移动文件
    $把= $ S3-> putObject($ S3-> INPUTFILE($ imageTempName),小部件图像,$ imageName,S3 :: ACL_PUBLIC_READ);
    如果($放){
        后续代码var_dump($放);
        $ imageUploaded = TRUE;
    }其他{
        $ imageUploaded = FALSE;
    }
    回声($ imageUploaded);
}否则$图像= $ IMAGELINK;
 

解决方案

您计算机的时钟或时区设置不正确。由于S3使用当前时间来验证请求,如果你的时钟是关闭的时间超过15分钟,或者如果你的时区不正确(从而导致数小时歪斜),您的请求将会失败。

This is my first PHP project, so I really don't know PHP at all.

What I am trying to do is upload a file to an S3 bucket using the PHP S3 class. An example snippet of code was working yesterday, but when I went to start working with it again today, almost the exact same code stopped working.

Now I just get the following error returned by the putObject function:

Warning: S3::putObject(): RequestTimeTooSkewed The difference between the request time and the current time is too large. in /vagrant/LifeInYourWay/S3.php on line 222

I read some places that the server time could be causing the error so I changed my server time to America/New_York but still get the same thing.

The PHP code that I have is:

if(!class_exists('S3')) require_once('S3.php');

// AWS access
if(!defined('awsAccessKey')) define('awsAccessKey', '******');
if(!defined('awsSecretKey')) define('awsSecretKey', '******');

$s3 = new S3(awsAccessKey, awsSecretKey);

$imageName = $_FILES['imageFile']['name'];
$imageTempName = $_FILES['imageFile']['tmp_name'];
$imageLink = $_POST['imageLink'];

if(!strlen($imageLink) || $imageLink == 'http://'){
    //create a new bucket
    $s3->putBucket("widget-images", S3::ACL_PUBLIC_READ);

    //move the file
    $put = $s3->putObject($s3->inputFile($imageTempName), "widget-images", $imageName, S3::ACL_PUBLIC_READ);
    if($put){
        var_dump($put);
        $imageUploaded = true;
    }else{
        $imageUploaded = false;
    }
    echo($imageUploaded);
}else $image = $imageLink;

解决方案

Your computer's clock or time zone setting is incorrect. Because S3 uses the current time to authenticate requests, if your clock is off by more than 15 minutes, or if your time zone is incorrect (thus leading to a skew of hours), your requests will fail.

这篇关于使用PHP S3级RequestTimeTooSkewed错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆