首页   >   代码编程   >   JAVA开发

阿里云OSS上传文件出错“The bucket you are attempting to access must be addressed using the specified endpoint”

这两天建了一个新项目需要用oss,所以在创建了新的bucket之后,就直接将原来项目中的配置拷贝过来,结果分分钟报错:“The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.”,

详细错误信息如下:

com.aliyun.oss.OSSException: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
[ErrorCode]: AccessDenied
[RequestId]: 5DF9E1F5EB0E623731F77819
[HostId]: quartet-pay.oss-cn-shanghai.aliyuncs.com
[ResponseError]:
<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>AccessDenied</Code>
  <Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>
  <RequestId>5DF9E1F5EB0E623731F77819</RequestId>
  <HostId>quartet-pay.oss-cn-shanghai.aliyuncs.com</HostId>
  <Bucket>quartet-pay</Bucket>
  <Endpoint>oss-cn-beijing.aliyuncs.com</Endpoint>
</Error>

	at com.aliyun.oss.common.utils.ExceptionFactory.createOSSException(ExceptionFactory.java:100)
	at com.aliyun.oss.internal.OSSErrorResponseHandler.handle(OSSErrorResponseHandler.java:70)
	at com.aliyun.oss.common.comm.ServiceClient.handleResponse(ServiceClient.java:257)
	at com.aliyun.oss.common.comm.ServiceClient.sendRequestImpl(ServiceClient.java:140)
	at com.aliyun.oss.common.comm.ServiceClient.sendRequest(ServiceClient.java:70)
	at com.aliyun.oss.internal.OSSOperation.send(OSSOperation.java:83)
	at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:145)
	at com.aliyun.oss.internal.OSSOperation.doOperation(OSSOperation.java:102)
	at com.aliyun.oss.internal.OSSObjectOperation.writeObjectInternal(OSSObjectOperation.java:1125)
	at com.aliyun.oss.internal.OSSObjectOperation.putObject(OSSObjectOperation.java:130)
	at com.aliyun.oss.OSSClient.putObject(OSSClient.java:494)
	at com.aliyun.oss.OSSClient.putObject(OSSClient.java:478)
	at com.aliyun.oss.OSSClient.putObject(OSSClient.java:472)
	at com.wolffy.util.OssUtil.upload(OssUtil.java:74)
	at com.wolffy.util.OssUtil.main(OssUtil.java:192)

Process finished with exit code 0

一脸懵逼,仔细检查之后,发现是因为point地址写错了。。。

在创建了bucket之后,oss会根据选择的区域自动分配endpoint,我之前新建的bucket选择的是上海,而这个quartet-pay我选择的是北京,所以endpoint应该是oss-cn-beijing.aliyuncs.com,而不应该是oss-cn-shanghai.aliyuncs.com。

阿里云OSS上传文件出错“The bucket you are attempting to access must be addressed using the specified endpoint”

QQ群Ⅰ: 686430774 (已满)

QQ群Ⅱ: 718410762 (已满)

QQ群Ⅲ: 638620451 (已满)

QQ群Ⅳ: 474195684 (已满)

QQ群Ⅴ: 463034360 (已满)

QQ群Ⅵ: 879266502 (已满)

QQ群Ⅶ: 627786015 (已满)

工作5分钟,吹逼2小时: 855525339 (娱乐消遣,广告狗勿进)

如果文章有帮到你,可以考虑请博主喝杯咖啡!

分享到:

欢迎分享本文,转载请注明出处!

作者:不忘初心

发布时间:2020-01-09

永久地址:https://www.jiweichengzhu.com/article/e279080457084f3baff83a8eeae5cefb

评论