# S3 API reference

> Exports of @anymux/s3.

Source: https://anymux-docs.n.yatsyk.com/docs/s3/jsdoc

## Classes

### S3ObjectStorage

```ts
class S3ObjectStorage
```

- `constructor(config: S3Config): S3ObjectStorage`
- `listBuckets(): Promise<BucketInfo[]>`
- `createBucket(name: string): Promise<void>`
- `deleteBucket(name: string): Promise<void>`
- `bucketExists(name: string): Promise<boolean>`
- `getObject(bucket: string, key: string): Promise<Buffer>`
- `putObject(bucket: string, key: string, data: Buffer | Uint8Array | string, options?: PutObjectOptions): Promise<void>`
- `deleteObject(bucket: string, key: string): Promise<void>`
- `headObject(bucket: string, key: string): Promise<ObjectMetadata>`
- `copyObject(sourceBucket: string, sourceKey: string, destBucket: string, destKey: string): Promise<void>`
- `listObjects(bucket: string, options?: ListObjectsOptions): Promise<ListObjectsResult>`
- `getPresignedUrl(bucket: string, key: string, options?: PresignedUrlOptions): Promise<string>`
- `objectExists(bucket: string, key: string): Promise<boolean>`

### S3Provider

```ts
class S3Provider
```

- `id: string`
- `name: "Amazon S3"`
- `capabilities: readonly CapabilityType[]`
- `constructor(options: S3ProviderOptions): S3Provider`
- `<T>(type: CapabilityType): T | undefined`
- `hasCapability(type: CapabilityType): boolean`

## Types

### S3Config

```ts
type S3Config = { region?: string; endpoint?: string; credentials?: { accessKeyId?: string; secretAccessKey?: string; }; forcePathStyle?: boolean; bucket?: string; }
```

## Interfaces

### S3ProviderOptions

```ts
interface S3ProviderOptions
```

- `id: string`
- `config: { region?: string; endpoint?: string; credentials?: { accessKeyId?: string; secretAccessKey?: string; }; forcePathStyle?: boolean; bucket?: string; }`

## Constants

### S3ConfigSchema

```ts
const S3ConfigSchema: z.ZodObject<{ region: z.ZodString; endpoint: z.ZodOptional<z.ZodString>; credentials: z.ZodOptional<z.ZodObject<{ accessKeyId: z.ZodString; secretAccessKey: z.ZodString; }, "strip", z.ZodTypeAny, { accessKeyId?: string; secretAccessKey?: string; }, { accessKeyId?: string; secretAccessKey?: string; }>>; forcePathStyle: z.ZodOptional<z.ZodBoolean>; bucket: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { region?: string; endpoint?: string; credentials?: { accessKeyId?: string; secretAccessKey?: string; }; forcePathStyle?: boolean; bucket?: string; }, { region?: string; endpoint?: string; credentials?: { accessKeyId?: string; secretAccessKey?: string; }; forcePathStyle?: boolean; bucket?: string; }>
```
