mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-03-13 00:26:39 +00:00
fix(s3-backend): let minio lib handle the port fallback
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
a72f695124
commit
2016874a3d
1 changed files with 17 additions and 15 deletions
|
@ -25,22 +25,24 @@ export class S3Backend implements MediaBackend {
|
||||||
private mediaConfig: MediaConfig,
|
private mediaConfig: MediaConfig,
|
||||||
) {
|
) {
|
||||||
this.logger.setContext(S3Backend.name);
|
this.logger.setContext(S3Backend.name);
|
||||||
if (mediaConfig.backend.use === BackendType.S3) {
|
if (mediaConfig.backend.use !== BackendType.S3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.config = mediaConfig.backend.s3;
|
this.config = mediaConfig.backend.s3;
|
||||||
const url = new URL(this.config.endPoint);
|
const url = new URL(this.config.endPoint);
|
||||||
const secure = url.protocol === 'https:'; // url.protocol contains a trailing ':'
|
const isSecure = url.protocol === 'https:';
|
||||||
let port = parseInt(url.port);
|
|
||||||
if (isNaN(port)) {
|
|
||||||
port = secure ? 443 : 80;
|
|
||||||
}
|
|
||||||
this.client = new Client({
|
this.client = new Client({
|
||||||
endPoint: url.hostname,
|
endPoint: url.hostname,
|
||||||
port: port,
|
port: this.determinePort(url),
|
||||||
useSSL: secure,
|
useSSL: isSecure,
|
||||||
accessKey: this.config.accessKeyId,
|
accessKey: this.config.accessKeyId,
|
||||||
secretKey: this.config.secretAccessKey,
|
secretKey: this.config.secretAccessKey,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private determinePort(url: URL): number | undefined {
|
||||||
|
const port = parseInt(url.port);
|
||||||
|
return isNaN(port) ? undefined : port;
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveFile(
|
async saveFile(
|
||||||
|
|
Loading…
Reference in a new issue