mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-03-12 19:52:34 +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,
|
||||
) {
|
||||
this.logger.setContext(S3Backend.name);
|
||||
if (mediaConfig.backend.use === BackendType.S3) {
|
||||
if (mediaConfig.backend.use !== BackendType.S3) {
|
||||
return;
|
||||
}
|
||||
this.config = mediaConfig.backend.s3;
|
||||
const url = new URL(this.config.endPoint);
|
||||
const secure = url.protocol === 'https:'; // url.protocol contains a trailing ':'
|
||||
let port = parseInt(url.port);
|
||||
if (isNaN(port)) {
|
||||
port = secure ? 443 : 80;
|
||||
}
|
||||
const isSecure = url.protocol === 'https:';
|
||||
this.client = new Client({
|
||||
endPoint: url.hostname,
|
||||
port: port,
|
||||
useSSL: secure,
|
||||
port: this.determinePort(url),
|
||||
useSSL: isSecure,
|
||||
accessKey: this.config.accessKeyId,
|
||||
secretKey: this.config.secretAccessKey,
|
||||
});
|
||||
}
|
||||
|
||||
private determinePort(url: URL): number | undefined {
|
||||
const port = parseInt(url.port);
|
||||
return isNaN(port) ? undefined : port;
|
||||
}
|
||||
|
||||
async saveFile(
|
||||
|
|
Loading…
Reference in a new issue