Amazon web services 使用AmazonS3的精细上传程序
我正在为AmazonS3使用精细上传器,但当我尝试上传文件时。 错误显示:不支持您提供的授权机制。请使用AWS4-HMAC-SHA256。 页面Url:Amazon web services 使用AmazonS3的精细上传程序,amazon-web-services,amazon-s3,fine-uploader,Amazon Web Services,Amazon S3,Fine Uploader,我正在为AmazonS3使用精细上传器,但当我尝试上传文件时。 错误显示:不支持您提供的授权机制。请使用AWS4-HMAC-SHA256。 页面Url: var s3Uploader=新的qq.s3.FineUploader({ 是的, 元素:document.getElementById('fine-uploader-s3'), 模板:“qq-template-s3”, 请求:{ 端点:“mybucketname.s3.amazonaws.com”, accessKey:“这是我的钥匙” }
var s3Uploader=新的qq.s3.FineUploader({
是的,
元素:document.getElementById('fine-uploader-s3'),
模板:“qq-template-s3”,
请求:{
端点:“mybucketname.s3.amazonaws.com”,
accessKey:“这是我的钥匙”
},
签名:{
端点:“s3demo缩略图cors.php”
},
上载成功:{
端点:“s3demo缩略图cors.php?成功”,
参数:{
iBrowserPreviewCapable:qq.supportedFeatures.imagePreviews
}
},
iframeSupport:{
localBlankPagePath:“success.html”
},
cors:{
预期:正确
},
分块:{
已启用:true
},
简历:{
已启用:true
},
删除文件:{
启用:对,
方法:“张贴”,
端点:“s3demo缩略图cors.php”
},
验证:{
项目限额:5,
限额:15000000
},
缩略图:{
占位符:{
notAvailablePath:“not_available-generic.png”,
waitingPath:“waiting generic.png”
}
},
回调:{
onComplete:函数(id、名称、响应){
var previewLink=qq(this.getItemByFileId(id)).getByClass('preview-link')[0];
if(response.success){
previewLink.setAttribute(“href”,response.tempLink)
}
}
} });
需要“aws autoloader.php”;
使用Aws\S3\S3客户端;
//实例化AmazonS3客户机。
$s3=新的Aws\s3\s3客户端([
'版本'=>'最新',
“地区”=>“美国西部1号”,
“凭据”=>false,
“签名版本”=>“v4”
]);
//
//这些设置假定您在中存储了相关的AWS密钥
//关联的系统环境变量
$clientPrivateKey=“私钥”;
//仅当启用了“删除文件”功能时,才需要这两个键
//或者,例如,如果正在确认后续点中的文件大小
//通过S3的SDK处理程序,正如我们在本例中所做的。
$serverPublicKey=“key”//$_服务器['PARAM1'];
$serverPrivateKey=“私钥”//$_服务器['PARAM2'];
//验证策略文档时使用以下变量
//由上载者发送:
$expectedBucketName=“bucket name”;
当您的区域不正确匹配时,此错误很常见。您可能需要仔细检查您在代码中指定的区域是否与您创建的bucket匹配。$clientPrivateKey=$\u ENV['AWS\u CLIENT\u SECRET\u KEY'];//仅当启用了删除文件功能//或者您正在通过S3的SDK确认successEndpoint//处理程序中的文件大小时,才需要这两个键,正如我们在本例中所做的那样$serverPublicKey=$_ENV['AWS_SERVER_PUBLIC_KEY']$serverPrivateKey=$\u ENV['AWS\u服务器\u私钥'];我发现$serverPublicKey=$\u ENV['AWS\u SERVER\u PUBLIC\u KEY']$serverPrivateKey=$\u ENV['AWS\u服务器\u私钥'];如何找到这把钥匙
<script>
var s3Uploader = new qq.s3.FineUploader({
debug: true,
element: document.getElementById('fine-uploader-s3'),
template: 'qq-template-s3',
request: {
endpoint: 'mybucketname.s3.amazonaws.com',
accessKey: "here is my key"
},
signature: {
endpoint: "s3demo-thumbnails-cors.php"
},
uploadSuccess: {
endpoint: "s3demo-thumbnails-cors.php?success",
params: {
isBrowserPreviewCapable: qq.supportedFeatures.imagePreviews
}
},
iframeSupport: {
localBlankPagePath: "success.html"
},
cors: {
expected: true
},
chunking: {
enabled: true
},
resume: {
enabled: true
},
deleteFile: {
enabled: true,
method: "POST",
endpoint: "s3demo-thumbnails-cors.php"
},
validation: {
itemLimit: 5,
sizeLimit: 15000000
},
thumbnails: {
placeholders: {
notAvailablePath: "not_available-generic.png",
waitingPath: "waiting-generic.png"
}
},
callbacks: {
onComplete: function(id, name, response) {
var previewLink = qq(this.getItemByFileId(id)).getByClass('preview-link')[0];
if (response.success) {
previewLink.setAttribute("href", response.tempLink)
}
}
} });
</script>
require 'aws-autoloader.php';
use Aws\S3\S3Client;
// Instantiate an Amazon S3 client.
$s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => 'us-west-1',
'credentials' => false,
'signature_version'=> 'v4'
]);
//
// These assume you have the associated AWS keys stored in
// the associated system environment variables
$clientPrivateKey ="private key";
// These two keys are only needed if the delete file feature is enabled
// or if you are, for example, confirming the file size in a successEndpoint
// handler via S3's SDK, as we are doing in this example.
$serverPublicKey = "key";//$_SERVER['PARAM1'];
$serverPrivateKey = "private key";//$_SERVER['PARAM2'];
// The following variables are used when validating the policy document
// sent by the uploader:
$expectedBucketName = "bucket name";