gpt4 book ai didi

java - 使用java将对象放入S3但没有从控制台看到任何对象

转载 作者:行者123 更新时间:2023-12-02 01:00:12 24 4
gpt4 key购买 nike

我尝试使用以下代码将字符串放入 S3 中。我看到该文件夹​​是在存储桶下创建的,但没有在该文件夹中看到任何对象。我错过了什么?

String SUFFIX = "/";

try
{
s3client.putObject(bucketName, today.toString() + SUFFIX + source + SUFFIX, "abc");
}
catch (Exception e)
{
e.printStackTrace();
}

我不认为这是一个权限问题,因为我有上面代码创建的那些文件夹,并且 try-catch 也没有捕获到异常。

请帮忙。谢谢

最佳答案

来自Amazon S3 folders documentation :

The Amazon S3 console treats all objects that have a forward slash (/) character as the last (trailing) character in the key name as a folder, for example examplekeyname/. You can't upload an object that has a key name with a trailing / character using the Amazon S3 console.

However, you can upload objects that are named with a trailing / with the Amazon S3 API by using the AWS CLI, AWS SDKs, or REST API.

An object that is named with a trailing "/" appears as a folder in the Amazon S3 console.

因此,在您的情况下,删除尾部斜杠应该可以完成工作:

String SUFFIX = "/";
try {
s3client.putObject(bucketName, today.toString() + SUFFIX + source, "abc");
} catch (Exception e) {
e.printStackTrace();
}

关于java - 使用java将对象放入S3但没有从控制台看到任何对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60763911/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com