Skip to content

Commit bc3eadd

Browse files
authored
feat: support for self-hosted compatible services (#396)
* feat: support for self-hosted compatible services * making region optional and updating readme
1 parent d6f3043 commit bc3eadd

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Supported providers with their required environment variables:
414414
| [`mux`](https://mux.com?utm_source=next-video.dev) (default) | `MUX_TOKEN_ID`<br/>`MUX_TOKEN_SECRET` | [`videoQuality`](https://www.mux.com/docs/guides/use-video-quality-levels?utm_source=next-video.dev): `'basic' \| 'plus' \| 'premium'` (optional) | [Pricing](https://www.mux.com/pricing/video?utm_source=next-video.dev) |
415415
| [`vercel-blob`](https://vercel.com/docs/storage/vercel-blob) | `BLOB_READ_WRITE_TOKEN` | | [Pricing](https://vercel.com/docs/storage/vercel-blob/usage-and-pricing) |
416416
| [`backblaze`](https://www.backblaze.com/cloud-storage) | `BACKBLAZE_ACCESS_KEY_ID`<br/>`BACKBLAZE_SECRET_ACCESS_KEY` | `endpoint`<br/>`bucket` (optional) | [Pricing](https://www.backblaze.com/cloud-storage/pricing) |
417-
| [`amazon-s3`](https://aws.amazon.com/s3) | `AWS_ACCESS_KEY_ID`<br/>`AWS_SECRET_ACCESS_KEY` | `endpoint`<br/>`bucket` (optional) | [Pricing](https://aws.amazon.com/s3/pricing/) |
417+
| [`amazon-s3`](https://aws.amazon.com/s3) | `AWS_ACCESS_KEY_ID`<br/>`AWS_SECRET_ACCESS_KEY` | `endpoint`<br/>`bucket` (optional)<br/>`region` (optional, defaults to `us-east-1` or auto-extracted from endpoint) | [Pricing](https://aws.amazon.com/s3/pricing/) |
418418
| [`cloudflare-r2`](https://developers.cloudflare.com/r2/) | `R2_ACCESS_KEY_ID`<br/>`R2_SECRET_ACCESS_KEY`<br/>`R2_CF_API_TOKEN` (optional when `bucketUrlPublic` set) | `bucket` (optional)<br/>`bucketUrlPublic` (optional when `R2_CF_API_TOKEN` set) | [Pricing](https://developers.cloudflare.com/r2/pricing/) |
419419

420420
#### Provider feature set

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export type ProviderConfig = {
6464
bucket?: string;
6565
accessKeyId?: string;
6666
secretAccessKey?: string;
67+
region?: string;
6768
/* An optional function to generate the bucket asset key. */
6869
generateAssetKey?: (filePathOrURL: string, folder: string) => string;
6970
};

src/providers/amazon-s3/provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ async function initS3() {
3737
bucketName = amazonS3Config?.bucket ?? '';
3838
endpoint = amazonS3Config?.endpoint ?? '';
3939

40+
const configuredRegion = amazonS3Config?.region;
4041
const regionMatch = endpoint.match(/\.([a-z0-9-]+)\.amazonaws\.com$/);
41-
const region = regionMatch ? regionMatch[1] : '';
42+
const extractedRegion = regionMatch ? regionMatch[1] : '';
43+
const region = configuredRegion || extractedRegion || 'us-east-1';
4244

4345
s3 ??= new S3Client({
4446
endpoint,

0 commit comments

Comments
 (0)