S3afilesystem -S3访问密钥和秘密密钥

发布于 2025-01-19 20:21:00 字数 669 浏览 1 评论 0原文

我正在尝试读/编写S3存储桶并在Java中开发代码。在运行代码时,我会收到访问密钥和秘密密钥的授权错误。

我已经定义了FS如下:

Configuration conf = new Configuration()
S3AFileSystem fs = (S3AFileSystem) FileSystem.get(conf)
FSDataOutputStream ostm = fs.open(new Path(s3bucketpath))

当它创建FS时,它正在引发一个错误:

shaded.databricks.org.apache.hadoop.fs.s3a.S3AFileSystem cannot be cast to org.apache.hadoop.fs.s3a.S3AFileSystem
java.lang.ClassCastException: shaded.databricks.org.apache.hadoop.fs.s3a.S3AFileSystem cannot be cast to org.apache.hadoop.fs.s3a.S3AFileSystem

看起来它正在寻找访问密钥和秘密键,同时创建FS,并且有人可以指导我如何将它们传递到文件系统(conf)。

如果您可以指导我实施此示例代码,请提供示例代码。

谢谢

I am trying to read/write the S3 bucket and develop code in JAVA. While I am running the code I am getting authorization error for Access key and Secret key.

I have defined fs as follows:

Configuration conf = new Configuration()
S3AFileSystem fs = (S3AFileSystem) FileSystem.get(conf)
FSDataOutputStream ostm = fs.open(new Path(s3bucketpath))

while it is creating fs, it is throwing an error :

shaded.databricks.org.apache.hadoop.fs.s3a.S3AFileSystem cannot be cast to org.apache.hadoop.fs.s3a.S3AFileSystem
java.lang.ClassCastException: shaded.databricks.org.apache.hadoop.fs.s3a.S3AFileSystem cannot be cast to org.apache.hadoop.fs.s3a.S3AFileSystem

Looks like it is looking for access key and secret key while creating fs and could someone guide me how we can pass them to FileSystem(conf).

Please provide sample code if you can guide me to implement this.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文