Access Buckit with AWS SDK

This page shows how to access Buckit using the AWS SDK and documents the S3 APIs supported by Buckit Object Storage. For reference documentation on any given API, see the corresponding documentation for Amazon S3.

Use AWS SDK

The following examples connect to a Buckit deployment using an S3-compatible endpoint and perform basic PUT and GET object operations.

Replace the following placeholders before running the examples:

  • https://buckit.example.net

  • ACCESS_KEY

  • SECRET_KEY

  • my-bucket

  • hello.txt

For local or non-TLS test environments, you can use an http:// endpoint. For TLS-enabled deployments, use https://.

AWS SDK for Java

import java.net.URI;
import java.nio.file.Path;
import java.nio.charset.StandardCharsets;

import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.core.ResponseBytes;
import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.PutObjectRequest;

public class BuckitAwsJavaExample {
    public static void main(String[] args) {
        S3Client s3 = S3Client.builder()
            // Point the AWS SDK to the Buckit S3 endpoint.
            .endpointOverride(URI.create("https://buckit.example.net"))
            // Required by the AWS SDK for SigV4 request signing.
            // If Buckit has a server region configured, this value must match it.
            // If no server region is configured, us-east-1 is a common default.
            .region(Region.US_EAST_1)
            // Use path-style requests for broad S3-compatible compatibility.
            .forcePathStyle(true)
            .credentialsProvider(
                StaticCredentialsProvider.create(
                    AwsBasicCredentials.create("ACCESS_KEY", "SECRET_KEY")
                )
            )
            .build();

        PutObjectRequest putRequest = PutObjectRequest.builder()
            .bucket("my-bucket")
            .key("hello.txt")
            .build();

        // Upload a local file to Buckit.
        s3.putObject(
            putRequest,
            RequestBody.fromFile(Path.of("/path/to/hello.txt"))
        );

        GetObjectRequest getRequest = GetObjectRequest.builder()
            .bucket("my-bucket")
            .key("hello.txt")
            .build();

        // Read the same object back from Buckit.
        ResponseBytes<GetObjectResponse> object = s3.getObjectAsBytes(getRequest);

        System.out.println(object.asString(StandardCharsets.UTF_8));

        DeleteObjectRequest deleteRequest = DeleteObjectRequest.builder()
            .bucket("my-bucket")
            .key("hello.txt")
            .build();

        // Delete the object from Buckit.
        s3.deleteObject(deleteRequest);
        s3.close();
    }
}

AWS SDK for JavaScript

import { readFile } from "node:fs/promises";
import {
  S3Client,
  PutObjectCommand,
  GetObjectCommand,
  DeleteObjectCommand,
} from "@aws-sdk/client-s3";

const client = new S3Client({
  // Required by the AWS SDK for SigV4 request signing.
  // If Buckit has a server region configured, this value must match it.
  // If no server region is configured, us-east-1 is a common default.
  region: "us-east-1",
  // Point the AWS SDK to the Buckit S3 endpoint.
  endpoint: "https://buckit.example.net",
  // Use path-style requests for broad S3-compatible compatibility.
  forcePathStyle: true,
  credentials: {
    accessKeyId: "ACCESS_KEY",
    secretAccessKey: "SECRET_KEY",
  },
});

const fileBody = await readFile("/path/to/hello.txt");

// Upload a local file to Buckit.
await client.send(
  new PutObjectCommand({
    Bucket: "my-bucket",
    Key: "hello.txt",
    Body: fileBody,
  })
);

// Read the same object back from Buckit.
const response = await client.send(
  new GetObjectCommand({
    Bucket: "my-bucket",
    Key: "hello.txt",
  })
);

const body = await response.Body.transformToString();
console.log(body);

// Delete the object from Buckit.
await client.send(
  new DeleteObjectCommand({
    Bucket: "my-bucket",
    Key: "hello.txt",
  })
);

AWS SDK for Python

from pathlib import Path

import boto3

client = boto3.client(
    "s3",
    endpoint_url="https://buckit.example.net",
    aws_access_key_id="ACCESS_KEY",
    aws_secret_access_key="SECRET_KEY",
    # Required by the AWS SDK for SigV4 request signing.
    # If Buckit has a server region configured, this value must match it.
    # If no server region is configured, us-east-1 is a common default.
    region_name="us-east-1",
    # Use path-style requests for broad S3-compatible compatibility.
    config=boto3.session.Config(s3={"addressing_style": "path"}),
)

# Upload a local file to Buckit.
client.put_object(
    Bucket="my-bucket",
    Key="hello.txt",
    Body=Path("/path/to/hello.txt").read_bytes(),
)

# Read the same object back from Buckit.
response = client.get_object(Bucket="my-bucket", Key="hello.txt")
body = response["Body"].read().decode("utf-8")
print(body)

# Delete the object from Buckit.
client.delete_object(Bucket="my-bucket", Key="hello.txt")

Supported S3 APIs

Object APIs

Object Locking

Unsupported API Object Endpoints

GetObjectAcl
PutObjectAcl

Multipart Uploads

Differences from S3 APIs for Multipart Uploads

  • ListMultipartUploads requires the exact object name as a prefix.

  • The AbortIncompleteMultipartUpload lifecycle action is not supported with PutBucketLifecycle.

Bucket APIs

Bucket Replication

Bucket Lifecycle

Bucket Notifications

Bucket Policies

Unsupported API Bucket Operations

GetBucketInventoryConfiguration
PutBucketInventoryConfiguration
DeleteBucketInventoryConfiguration
PutBucketCors
DeleteBucketCors
GetBucketMetricsConfiguration
PutBucketMetricsConfiguration
DeleteBucketMetricsConfiguration
PutBucketWebsite
GetBucketLogging
PutBucketLogging
PutBucketAccelerateConfiguration
DeleteBucketAccelerateConfiguration
PutBucketRequestPayment
DeleteBucketRequestPayment
PutBucketAcl
HeadBucketAcl
GetPublicAccessBlock
PutPublicAccessBlock
DeletePublicAccessBlock
GetBucketOwnershipControls
PutBucketOwnershipControls
DeleteBucketOwnershipControls
GetBucketIntelligentTieringConfiguration
PutBucketIntelligentTieringConfiguration
ListBucketIntelligentTieringConfigurations
DeleteBucketIntelligentTieringConfiguration
GetBucketAnalyticsConfiguration
PutBucketAnalyticsConfiguration
ListBucketAnalyticsConfigurations
DeleteBucketAnalyticsConfiguration
CreateSession

Buckit alternatives for unsupported Bucket resources

  • For calls to BucketACL or ObjectACL operations, use Policies.

  • Calls to BucketCORS operations are not needed because CORS is enabled by default on all buckets for all HTTP verbs.

  • For calls to BucketWebsite operations, use caddy or nginx.

  • For calls to BucketAnalytics, BucketMetrics, or BucketLogging operations, use Bucket Notifications.