mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(media): ✨ Add path_style and path configuration to S3
This commit is contained in:
parent
5bb4e967a7
commit
404d63f6d0
|
|
@ -449,6 +449,8 @@ export const ConfigSchema = z
|
||||||
public_url: url.describe(
|
public_url: url.describe(
|
||||||
"Public URL that uploaded media will be accessible at",
|
"Public URL that uploaded media will be accessible at",
|
||||||
),
|
),
|
||||||
|
path: z.string().optional(),
|
||||||
|
path_style: z.boolean().default(true),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
validation: z.strictObject({
|
validation: z.strictObject({
|
||||||
|
|
|
||||||
|
|
@ -159,11 +159,15 @@ export class Media extends BaseInterface<typeof Medias> {
|
||||||
bucket: config.s3.bucket_name,
|
bucket: config.s3.bucket_name,
|
||||||
accessKeyId: config.s3.access_key,
|
accessKeyId: config.s3.access_key,
|
||||||
secretAccessKey: config.s3.secret_access_key,
|
secretAccessKey: config.s3.secret_access_key,
|
||||||
|
virtualHostedStyle: !config.s3.path_style,
|
||||||
});
|
});
|
||||||
|
|
||||||
await client.write(path, file);
|
await client.write(path, file);
|
||||||
|
const finalPath = config.s3.path
|
||||||
|
? join(config.s3.path, path)
|
||||||
|
: path;
|
||||||
|
|
||||||
return { path };
|
return { path: finalPath };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,6 +153,12 @@ convert_vectors = false
|
||||||
# region = "us-east-1"
|
# region = "us-east-1"
|
||||||
# bucket_name = "versia"
|
# bucket_name = "versia"
|
||||||
# public_url = "https://cdn.example.com"
|
# public_url = "https://cdn.example.com"
|
||||||
|
# Adds a prefix to the uploaded files
|
||||||
|
# path = "versia"
|
||||||
|
# Use path-style URLs during upload (e.g. https://s3.example.com/versia)
|
||||||
|
# instead of the default virtual-hosted style (e.g. https://versia.s3.example.com)
|
||||||
|
# This is required for some S3-compatible services, such as MinIO
|
||||||
|
# path_style = true
|
||||||
|
|
||||||
[validation]
|
[validation]
|
||||||
# Checks user data
|
# Checks user data
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue