AWS BOTO3 S3 python-调用HeadObject操作时发生错误(404):找不到 [英] AWS BOTO3 S3 python - An error occurred (404) when calling the HeadObject operation: Not Found

查看:891
本文介绍了AWS BOTO3 S3 python-调用HeadObject操作时发生错误(404):找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在s3存储桶中下载目录.我正在尝试使用传输从S3存储桶下载目录,但出现错误,因为调用HeadObject操作时发生错误(404):未找到".请帮忙.

I am trying download a directory inside s3 bucket. I am trying to use transfer to download a directory from S3 bucket but I am getting an error as "An error occurred (404) when calling the HeadObject operation: Not Found". Please help.

S3 structure:
  **Bucket
     Folder1
        File1**

注意:尝试下载Folder1

Note: Trying to download Folder1

transfer.download_file(self.bucket_name, self.dir_name, self.file_dir + self.dir_name)

推荐答案

我最近遇到了同样的问题.您可能拼错了路径和文件夹名称.以我为例,我搞砸了"/".

I had the same issue recently. You are probably misspelling the path and folder name. In my case, for example, I was messing up with the '/'.

要对其进行修复,请确保要用作函数参数的变量包含与S3中相同的目录,文件夹和文件的正确名称.另外,请确保将"/"放在正确的变量中的正确位置.例如,就我而言,我发现:

To fix it, make sure the variables you are using as arguments for the function contains the correct names of the directories, folders and files as it is in S3. Also, make sure you put the '/' in the correct places in the correct variables. For instance, in my case I found that:

  • 存储桶名称: bucket_name (末尾没有'/',也没有's3://')
  • 目录名称: folder1/folder2/file_name (开头没有'/')
  • bucket name: bucket_name (with no '/' in the end, and no 's3://')
  • directory name: folder1/folder2/file_name (with no '/' in the beginning)

我希望它可以帮助您和其他人轻松解决此错误.

I hope it helps you and others to get around this error easily.

这篇关于AWS BOTO3 S3 python-调用HeadObject操作时发生错误(404):找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆