For the complete documentation index, see llms.txt. This page is also available as Markdown.

S3 API Usage

使用示例

S3 API 操作

AWS CLI

您可以使用 AWS 命令行接口 向 Alluxio S3 API 发送 S3 API 请求。 请注意,您必须提供 --endpoint参数来指定 Alluxio S3 REST API 的位置,并包含服务器的基本 URI。 端点格式为 --endpoint "http://{alluxio.worker.web.hostname}:{alluxio.worker.rest.port}/"

如涉及 授权 标头操作,您可能需要先配置 AWS 凭证

  • 有关 Alluxio 如何使用该标头的详细信息,请参阅授权标头

$ aws configure --profile alluxio-s3
AWS Access Key ID [None]: {user}
AWS Secret Access Key [None]: {dummy value}
Default region name [None]:
Default output format [None]:
REST Clients

您可以直接使用任何 HTTP client 向 Alluxio S3 API 发送 S3 API 请求。 基本 URI 为 /;请求应指向 http://{alluxio.worker.web.hostname}:{alluxio.worker.rest.port}/

目前,Alluxio S3 API 不存在access key和secret key验证。 因此,授权标头仅用于指定执行请求的目标用户。 The header follows the AWS Signature Version 4 format.

$ curl -i -H "Authorization: AWS4-HMAC-SHA256 Credential=testuser/..." ...

AbortMultipartUpload

AWS CLI
$ aws --profile alluxio-s3 --endpoint "http://localhost:29998/" s3api list-objects-v2 \
  --bucket=testbucket
{
    "Contents": [
        {
            "Key": "multipart_copy.txt_6367cf96-ea4e-4447-b931-c5bc91200375/",
            "LastModified": "2022-05-03T13:00:13.429000+00:00",
            "Size": 0
        },
        {
            "Key": "multipart_copy.txt_6367cf96-ea4e-4447-b931-c5bc91200375/1",
            "LastModified": "2022-05-03T13:00:13.584000+00:00",
            "Size": 27040
        },
        {
            "Key": "test.txt",
            "LastModified": "2022-05-03T11:55:01.925000+00:00",
            "Size": 27040
        }
    ]
}

$ aws --profile alluxio-s3 --endpoint "http://localhost:29998/" s3api abort-multipart-upload \
  --bucket=testbucket --key=multipart_copy.txt --upload-id=6367cf96-ea4e-4447-b931-c5bc91200375

$ % aws --profile alluxio-s3 --endpoint "http://localhost:29998/" s3api list-objects-v2 \
  --bucket=testbucket
{
    "Contents": [
        {
            "Key": "test.txt",
            "LastModified": "2022-05-03T11:55:01.925000+00:00",
            "Size": 27040
        }
    ]
}
REST Clients
$ curl -i -H "Authorization: AWS4-HMAC-SHA256 Credential=testuser/..." \
  -X GET "http://localhost:29998/testbucket"
HTTP/1.1 200 OK
Date: Tue, 03 May 2022 23:45:17 GMT
Content-Type: application/xml
Content-Length: 583
Server: Jetty(9.4.43.v20210629)

<ListBucketResult>
  <version2>false</version2>
  <Marker/>
  <Prefix/>
  <IsTruncated>false</IsTruncated>
  <Name>testbucket</Name>
  <Contents>
    <Key>multipart.txt_6367cf96-ea4e-4447-b931-c5bc91200375/</Key>
    <Size>0</Size>
    <LastModified>2022-05-03T16:44:17.490Z</LastModified>
  </Contents>
  <Contents>
    <Key>multipart.txt_6367cf96-ea4e-4447-b931-c5bc91200375/1</Key>
    <Size>27040</Size>
    <LastModified>2022-05-03T16:44:17.715Z</LastModified>
  </Contents>
  <Contents>
    <Key>test.txt</Key>
    <Size>27040</Size>
    <LastModified>2022-05-03T14:47:36.600Z</LastModified>
  </Contents>
  <MaxKeys>1000</MaxKeys>
  <EncodingType>url</EncodingType>
</ListBucketResult>

$ curl -i -H "Authorization: AWS4-HMAC-SHA256 Credential=testuser/..." \
  -X DELETE "http://localhost:29998/testbucket/multipart.txt?uploadId=6367cf96-ea4e-4447-b931-c5bc91200375"
HTTP/1.1 204 No Content
Date: Tue, 03 May 2022 23:45:30 GMT
Server: Jetty(9.4.43.v20210629)

$ curl -i -H "Authorization: AWS4-HMAC-SHA256 Credential=testuser/..." \
  -X GET "http://localhost:29998/testbucket"
HTTP/1.1 200 OK
Date: Tue, 03 May 2022 23:45:36 GMT
Content-Type: application/xml
Content-Length: 318
Server: Jetty(9.4.43.v20210629)

<ListBucketResult>
  <version2>false</version2>
  <Marker/>
  <Prefix/>
  <IsTruncated>false</IsTruncated>
  <Name>testbucket</Name>
  <Contents>
    <Key>test.txt</Key>
    <Size>27040</Size>
    <LastModified>2022-05-03T14:47:36.600Z</LastModified>
  </Contents>
  <MaxKeys>1000</MaxKeys>
  <EncodingType>url</EncodingType>
</ListBucketResult>

CompleteMultipartUpload

AWS CLI
REST Clients

CopyObject

AWS CLI
REST Clients

CreateBucket

AWS CLI
REST Clients

CreateMultipartUpload

AWS CLI
REST Clients

DeleteBucket

AWS CLI
REST Clients

DeleteBucketTagging

AWS CLI
REST Clients

DeleteObject

AWS CLI
REST Clients

DeleteObjects

AWS CLI
REST Clients

DeleteObjectTagging

AWS CLI
REST Clients

GetBucketTagging

AWS CLI
REST Clients

GetObject

AWS CLI
REST Clients

GetObjectTagging

AWS CLI
REST Clients

HeadBucket

AWS CLI
REST Clients

HeadObject

AWS CLI
REST Clients

ListBuckets

AWS CLI
REST Clients

ListMultipartUploads

AWS CLI
REST Clients

ListObjects

AWS CLI
REST Clients

ListObjectsV2

AWS CLI
REST Clients

ListParts

AWS CLI
REST Clients

PutBucketTagging

AWS CLI
REST Clients

PutObject

AWS CLI
REST Clients

PutObjectTagging

AWS CLI
REST Clients

UploadPart

AWS CLI
REST Clients

UploadPartCopy

AWS CLI
REST Clients

Last updated