如何使用卷发从Minio S3存储桶下载文件

发布于 2025-01-24 23:21:43 字数 550 浏览 3 评论 0原文

我正在尝试从Minio S3存储桶下载文件夹的内容。

我正在使用以下命令。

我可以使用特定文件使用特定文件

# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/requirements.txt .

,但如果尝试下载文件夹的所有内容,则下面会引发

# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/* . 
fatal error: An error occurred (404) when calling the HeadObject operation: Key "3/050d4b07b6334997b214713201e41012/artifacts/model/*" does not exist

错误

I am trying to download contents of a folder from a minio s3 bucket.

i am using the following command.

I am able to download a specific file using

# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/requirements.txt .

But the below throws an error if it try to download all the contents of the folder

# aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model/* . 
fatal error: An error occurred (404) when calling the HeadObject operation: Key "3/050d4b07b6334997b214713201e41012/artifacts/model/*" does not exist

Any help will be appreciated

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

老子叫无熙 2025-01-31 23:21:43

这是一个脚本文件,使用curlopenssl从Minio服务器使用中下载文件

./download_minio.sh <HOST> <KEY> <SECRET> <BUCKET> <FILE ON MINIO> <OUTPUT PATH>
# Example: 
./download_minio.sh example.url.com mykey mysecret bucket-name minio/path/to/file.txt.zst /download/path/to/file.txt.zst

脚本content download_minio.sh

#!/usr/bin/env sh

# Example: ./download_minio.sh example.url.com username password bucket-name minio/path/to/file.txt.zst /download/path/to/file.txt.zst

if [ -z $1 ]; then
  echo "You have NOT specified a MINIO URL!"
  exit 1
fi

if [ -z $2 ]; then
  echo "You have NOT specified a USERNAME!"
  exit 1
fi

if [ -z $3 ]; then
  echo "You have NOT specified a PASSWORD!"
  exit 1
fi

if [ -z $4 ]; then
  echo "You have NOT specified a BUCKET!"
  exit 1
fi

if [ -z $5 ]; then
  echo "You have NOT specified a MINIO FILE PATH!"
  exit 1
fi

if [ -z $6 ]; then
  echo "You have NOT specified a DOWNLOAD PATH!"
  exit 1
fi


# User Minio Vars
URL=$1
USERNAME=$2
PASSWORD=$3
BUCKET=$4
MINIO_PATH="/${BUCKET}/$5"
OUT_FILE=$6

# Static Vars
DATE=$(date -R --utc)
CONTENT_TYPE='application/zstd'
SIG_STRING="GET\n\n${CONTENT_TYPE}\n${DATE}\n${MINIO_PATH}"
SIGNATURE=`echo -en ${SIG_STRING} | openssl sha1 -hmac ${PASSWORD} -binary | base64`
PROTOCOL="https"

curl -o "${OUT_FILE}" \
    -H "Host: $URL" \
    -H "Date: ${DATE}" \
    -H "Content-Type: ${CONTENT_TYPE}" \
    -H "Authorization: AWS ${USERNAME}:${SIGNATURE}" \
    ${PROTOCOL}://$URL${MINIO_PATH}

justintimperio在github on github on github 创建

Here is a script file that uses cURL and openssl to download a file from a MinIO server

Usage:

./download_minio.sh <HOST> <KEY> <SECRET> <BUCKET> <FILE ON MINIO> <OUTPUT PATH>
# Example: 
./download_minio.sh example.url.com mykey mysecret bucket-name minio/path/to/file.txt.zst /download/path/to/file.txt.zst

Script content download_minio.sh :

#!/usr/bin/env sh

# Example: ./download_minio.sh example.url.com username password bucket-name minio/path/to/file.txt.zst /download/path/to/file.txt.zst

if [ -z $1 ]; then
  echo "You have NOT specified a MINIO URL!"
  exit 1
fi

if [ -z $2 ]; then
  echo "You have NOT specified a USERNAME!"
  exit 1
fi

if [ -z $3 ]; then
  echo "You have NOT specified a PASSWORD!"
  exit 1
fi

if [ -z $4 ]; then
  echo "You have NOT specified a BUCKET!"
  exit 1
fi

if [ -z $5 ]; then
  echo "You have NOT specified a MINIO FILE PATH!"
  exit 1
fi

if [ -z $6 ]; then
  echo "You have NOT specified a DOWNLOAD PATH!"
  exit 1
fi


# User Minio Vars
URL=$1
USERNAME=$2
PASSWORD=$3
BUCKET=$4
MINIO_PATH="/${BUCKET}/$5"
OUT_FILE=$6

# Static Vars
DATE=$(date -R --utc)
CONTENT_TYPE='application/zstd'
SIG_STRING="GET\n\n${CONTENT_TYPE}\n${DATE}\n${MINIO_PATH}"
SIGNATURE=`echo -en ${SIG_STRING} | openssl sha1 -hmac ${PASSWORD} -binary | base64`
PROTOCOL="https"

curl -o "${OUT_FILE}" \
    -H "Host: $URL" \
    -H "Date: ${DATE}" \
    -H "Content-Type: ${CONTENT_TYPE}" \
    -H "Authorization: AWS ${USERNAME}:${SIGNATURE}" \
    ${PROTOCOL}://$URL${MINIO_PATH}

Originaly created by JustinTimperio on Github

好倦 2025-01-31 23:21:43

我终于能够通过运行

aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model . --recursive 

一个我遇到的一个问题来获得它,因为我必须使用PIP安装使用AWS-CLI,因为这是我可以使用的唯一方法。

I was finally able to get it by running

aws --endpoint-url http://s3:9000 s3 cp s3://mlflow/3/050d4b07b6334997b214713201e41012/artifacts/model . --recursive 

The one problem i ran into was i had to use the aws-cli using pip install as that's the only way i could the --recursive option to work.

心如荒岛 2025-01-31 23:21:43

您也可以使用minio客户端并在minio命令上设置一个别名。这是官方文档展示如何显示如何显示如何显示如何显示使用minio客户端的Docker版本实现此目的:

docker pull minio/mc:edge
docker run -it --entrypoint=/bin/sh minio/mc
mc alias set <ALIAS> <YOUR-S3-ENDPOINT> [YOUR-ACCESS-KEY] [YOUR-SECRET-KEY] [--api API-SIGNATURE]

您可以在任何操作系统上安装客户端。

完成后,要从S3复制内容,您只需要这样做:

{minio_alias} cp {minio_s3_source} {destination}

You could also use the minio client and set an alias on minio command. Here is an example taken from the official documentation showing how to achieve this using the docker version of minio client:

docker pull minio/mc:edge
docker run -it --entrypoint=/bin/sh minio/mc
mc alias set <ALIAS> <YOUR-S3-ENDPOINT> [YOUR-ACCESS-KEY] [YOUR-SECRET-KEY] [--api API-SIGNATURE]

You can instead install the client on any OS.

Once done, to copy content from s3 you would only have to do this:

{minio_alias} cp {minio_s3_source} {destination}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文