我正在尝试在AWSS3中上传错误文件,但它显示错误,例如“您尝试访问的存储桶必须使用指定的端点进行寻址。请将所有将来的请求发送到此端点:”test9011960909.s3.amazonaws.com “”
我还指定'region'=> 'us-east-1'但仍然发生同样的错误。
当我指定
时它正在工作'Bucket' => $this->bucket,
但我想在主存储桶的子文件夹中上传文件
'Bucket' => $this->bucket . "/" . $PrefixFolderPath,
我已经应用了来自AWS S3: The bucket you are attempting to access must be addressed using the specified endpoint
的已批准答案但仍然得到相同的错误,我正在使用php
代码:
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
class AWSS3Factory {
private $bucket;
private $keyname;
public function __construct() {
$this->bucket = AWSS3_BucketName;
$this->keyname = AWSS3_AccessKey;
// Instantiate the client.
}
public function UploadFile($FullFilePath,$PrefixFolderPath="") {
try {
$s3 = S3Client::factory(array(
'credentials' => array(
'key' => MYKEY,
'secret' => MYSECKEY,
'region' => 'eu-west-1',
)
));
// Upload data.
$result = $s3->putObject(array(
'Bucket' => $this->bucket . "/" . $PrefixFolderPath,
'Key' => $this->keyname,
'SourceFile' => $FullFilePath,
'StorageClass' => 'REDUCED_REDUNDANCY'
));
return true;
// Print the URL to the object.
//echo $result['ObjectURL'] . "\n";
} catch (S3Exception $e) {
echo $e->getMessage() . "\n";
}
}
}
答案 0 :(得分:1)
您必须将var jsonObj = [{
"op": "add",
"path": "/fields/System.Title",
"value": "cecetest1"
}];
$.ajax({
url: 'http://tfsserver:8080/tfs/TeamProjectCollection/TeamProject/_apis/wit/workitems/$Task?api-version=1.0',
type: 'PATCH',
contentType: "application/json-patch+json",
data: JSON.stringify(jsonObj),
cache: false,
dataType: 'json',
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("domain\\username" + ":" + "password"));
},
})
不添加到$PrefixFolderPath
,而是添加到'Bucket'
:
'Key'
答案 1 :(得分:1)
您必须以另一种方式创建s3实例,如下所示:
$s3 = S3Client::factory([
'region' => '',
'credentials' => ['key' => '***', 'secret' => '***'],
'version' => 'latest',
]);