# Storage: files and S3

> Storage keeps files in buckets with an HTTP API and S3-compatible access. Use the SDK for uploads and signed links, or an S3 client on your server.

Source: https://docs.infaris.com/en/pulseguard/hosting-storage

## What it is

Storage keeps files in buckets with an HTTP API and S3-compatible access. Use the SDK for uploads and signed links, or an S3 client on your server.

## Quick start and CLI

```bash
infaris-guard hosting storage buckets
infaris-guard hosting storage attach <bucket> --site <siteId>
infaris-guard hosting storage lint
bun add @infaris/storage-js
```

## SDK and code

```ts
import { createStorageClientFromEnv } from '@infaris/storage-js';
// Server only; reads the variables of the attached bucket.
const storage = createStorageClientFromEnv();
const { data, error } = await storage.bucket.createSignedUrl('invoices/0042.pdf', 300);
if (error) throw error;
console.log(data);
```

## Secure defaults

Buckets start private. Browser access uses Infaris Auth and bucket rules or a short-lived signed URL. S3 secrets stay on the server. Attachments set `INFARIS_STORAGE_URL`, `INFARIS_STORAGE_BUCKET`, `INFARIS_STORAGE_S3_ENDPOINT`, `INFARIS_STORAGE_REGION`, `INFARIS_STORAGE_ACCESS_KEY_ID` and `INFARIS_STORAGE_SECRET_ACCESS_KEY`. Only `INFARIS_STORAGE_SECRET_ACCESS_KEY` is secret; `hosting env pull` gives you the rest.

## Limits

The SDK uses multipart uploads from 64 MiB. Upload limits and allowed file types belong to bucket configuration. S3 compatibility does not mean every AWS S3 feature is available. Check the location of the CDN route you use too.

## Virus scan

Every file has a scan status (`scanStatus` in the SDK): `pending`, `clean`, `infected`, `skipped` (too large),
`failed`, `off` (the bucket deliberately does not scan) or `not_scanned`. `not_scanned` means the platform has no virus
scanner. That only happens on dev and acceptance; production does not start without a scanner. Such a file is not
blocked, but never shown as clean either: Guard says "Not scanned: no virus scanner". **Scan again** includes these
files once a scanner is there.

## FAQ

**Use S3?** `storageS3Config()` from the SDK supplies S3 client configuration; use path style. **Browser upload?** Use a signed upload URL or Auth, never an access key. **Public file?** A signed URL grants temporary access without making the bucket public.
