amazon-s3 - 如何修复“致命错误:调用 HeadObject 操作时发生错误 (404):键“...”不存在”
问题描述
我正在尝试使用 Bash 脚本下载 NOAA GOES 数据。它适用于同事的计算机,但不适用于我的计算机。即使文件确实存在于 S3 存储桶中,我也会收到“致命错误”,这是一个任何人都可以从中下载的公共存储桶。当我在提示符下输入 aws s3 命令时,我可以毫无问题地下载文件,但无法使用文本文件和遍历文件条目的代码下载文件。有谁知道还有什么可能导致 HeadObject 错误?
我检查了拼写错误和处理正斜杠,但似乎没有任何问题。我可以在命令提示符下手动下载文件,但不能在遍历文件的变量时下载。
#!/bin/bash
#Purpose: Pulls GOES16 Full Disk data from Amazon Web Services S3 bucket
#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!
##############################################################################
# Clean files from previous script run
rm DesiredData.txt
rm FullList.txt
#
echo "Please be patient. Script is reading available GOES-16 files for today from AWS bucket."
#
获取当前日期
DAYS=`date +%j`
YEARS=`date +%Y`
频道
CHANNELS='C01 C02 C03'
ABI产品
PRODUCTS='L1b-RadF'
#
获取当前日期可用的远程文件列表并将列表发送到文本文件
for PRODUCT in $PRODUCTS; do
for YEAR in $YEARS; do
for DAY in $DAYS; do
aws s3 ls --recursive noaa-goes16/ABI-$PRODUCT/$YEAR/$DAY/ | awk '{print $3";"$4}' >> FullList.txt
done
done
done
从上面的输出文本文件中为通道 1-3 数据创建新列表
for CHANNEL in $CHANNELS; do
grep "$CHANNEL"_G16_s"$YEAR$DAY"[0-9][0-9][0][0] FullList.txt >> DesiredData.txt
done
#
从 DesiredData.txt 列表下载文件
for x in $(cat DesiredData.txt);
do
SIZE=$(echo $x | cut -d";" -f1)
FULLNAME=$(echo $x | cut -d";" -f2)
NAME=$(echo $x | cut -d"/" -f5)
echo "Processing file $FULLNAME"
if [ -f $NAME ]; then
echo "This file exists locally"
LOCALSIZE=$(du -sb $NAME | awk '{ print $1 }')
if [ $LOCALSIZE -ne $SIZE ]; then
echo "The size of the file is not the same as the remote file. Downloading again..."
aws s3 cp s3://noaa-goes16/"$FULLNAME" ./
else
echo "The size of the file matches the remote file. Not downloading it again."
fi
else
echo "This file does not exist locally, downloading..."
aws s3 cp s3://noaa-goes16/"$FULLNAME" ./
fi
done
当我运行此代码时,当它到达下载部分时,我得到以下信息:'致命错误:调用 HeadObject 操作时发生错误(404):键“ABI-L1b-RadF/2019/147/00/OR_ABI-L1b -RadF-M6C01_G16_..." 不存在'
解决方案
推荐阅读
- reactjs - react-bootstrap-typeahead TypeScript- Ref - getInstance does not exist
- java - JDA Events 更新版本后停止工作
- javascript - Why is message.client.users.cache.random() only getting people that have messaged?
- sql-server - SQL Server - 当数据很大时使用 IN 运算符时的查询性能
- python - Display a splash while app is unpacking from onefile mode PyInstaller
- perl - Is there a way to find out the name of the file stdout is redirected to in Perl?
- scala - scpaegoat: [error] java.lang.NoSuchMethodError: scala.tools.nsc.Global.reporter()Lscala/tools/nsc/reporters/Reporter;
- php - Find duplicates in table by checking 4 columns
- python - PyCharm Asks "Is this intentional?" When Passing the Proper Arguments to Constructor of Generic Class
- php - WooCommerce 中赠品的强制性兑换券