简体   繁体   English

Amazon S3 获取错误:“NoSuchKey”但是密钥确实存在

[英]Amazon S3 Fetching Error: "NoSuchKey" However Key Does Exist

I am trying to fetch a S3 Object using AWS Storage我正在尝试使用 AWS 存储获取 S3 Object

 fetchAvatar = async () => { try { const imageData = await Storage.get("public/public/us-east-2:/1597842961073/family.jpg") console.log(imageData) } catch (err) { console.log('error fetching avatar: ') console.log(err) } }

When I click on the link that the imageData provides I get NoSuchKey error, however it does exist当我单击 imageData 提供的链接时,出现 NoSuchKey 错误,但它确实存在钥匙的形象

I've made sure that the image is public and accessible by everyone, so there shouldn't be any authentication problems.我已经确保图像是公开的并且每个人都可以访问,因此不应该有任何身份验证问题。 I've also looked at similar issue to this and I made sure there is no spaces or a lot of special keys in my image keys.我也研究过与此类似的问题,并确保我的图像键中没有空格或很多特殊键。 I am kind of stumped on this...我有点被这个难住了...

So I figured out the reason, and it has to do something with AWS S3 Management.所以我弄清楚了原因,它必须与 AWS S3 Management 做一些事情。 For some reason that every time I upload an image, the folder will reset and become privet.由于某种原因,每次我上传图片时,文件夹都会重置并变成女贞。 When I remake the folders and image public manually I am able to render the image properly...So i guess it is more of AWS issue or bug that they need to fix I think当我手动重新制作文件夹和公开图像时,我能够正确渲染图像......所以我想他们需要修复的更多是 AWS 问题或错误我认为

I suggest to usejavascript aws sdk , you can get an object from the bucket like below:我建议使用javascript aws sdk ,你可以从下面的桶中得到一个 object :

 var params = {
    Bucket: "your-bucket-name", 
    Key: "yourFileName.jpg"
 };
 s3.getObject(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);  
 });

UPDATE:更新:

You can define your region when you create a s3 instance, like:您可以在创建 s3 实例时定义您的区域,例如:

const s3 = new S3({
  region: 'eu-central-1',
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS::S3::NoSuchKey 指定的键不存在 - AWS::S3::NoSuchKey The specified key does not exist AWS S3 存储桶通知 lambda 抛出异常(服务:Amazon S3;状态代码:404;错误代码:NoSuchKey) - AWS S3 bucket notification lambda throws exception (Service: Amazon S3; Status Code: 404; Error Code: NoSuchKey) AWS Lambda:调用 GetObject 操作时发生错误 (NoSuchKey):指定的键不存在 - AWS Lambda: An error occurred (NoSuchKey) when calling the GetObject operation: The specified key does not exist aws-sdk: NoSuchKey: 指定的密钥不存在? - aws-sdk: NoSuchKey: The specified key does not exist? 使用 boto3 在 Amazon S3 上的文件夹之间移动文件(指定的存储桶不存在错误) - Move files between folder on Amazon S3 using boto3 ( The specified bucket does not exist error) Amazon S3 图像获取 CORS Chrome 中的错误/错误,Firefox 中没有错误 - Amazon S3 image fetching CORS Error/Bug in Chrome, no errors in Firefox 使用存储在 Amazon s3 上的公钥获取错误 EXTERNAL_OAUTH_JWS_CANT_RETRIEVE_PUBLIC_KEY - Getting error EXTERNAL_OAUTH_JWS_CANT_RETRIEVE_PUBLIC_KEY with a public key stored on Amazon s3 CloudFront + S3 网站:应显示隐式索引文档时“指定的键不存在” - CloudFront + S3 Website: "The specified key does not exist" when an implicit index document should be displayed Amazon S3 是否有连接池? - Does Amazon S3 have a connection pool? Terraform 初始化错误:无法获取现有工作区:S3 存储桶不存在 - Terraform init Error: Failed to get existing workspaces: S3 bucket does not exist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM