I am trying to use the following REST client to upload files to Amazon S3: https://github.com/tpyo/amazon-s3-php-class
I am having trouble with it, though.
Through my terminal I can upload files like with the following command:
$cmd = "s3cmd put --acl开发者_开发百科-public --guess-mime-type " . $loc . " s3://censored/static/images/" . $filename;
I cannot actually run this using exec or shell_exec, though, so I am using the above REST client. Here is what I am trying to do, but it does not seem to work:
if ($s3->putObject($loc, "s3://censored/static/images/", $filename, S3::ACL_PUBLIC_READ)) {
echo "File Uploaded.";
} else {
echo "Failed to upload file.";
}
The above always fails, and I am not sure why. I would like to think it is because the I am not writing out the bucket directory string correctly because I am able to do s3->listBuckets() successfully. $loc
is the location on my hard drive of the file I want to upload to the S3 server. $filename
is the name that I want to call the uploaded file on the s3 server.
精彩评论