Skip to content

Commit

Permalink
fix(minio): support baseUrl for private endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Fenrikur committed Aug 4, 2024
1 parent a81757c commit 56940cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Eurofurence.App.Server.Services.Abstractions.MinIO
public class MinIoConfiguration
{
public string Endpoint { get; set; }
public string BaseUrl { get; set; }
public string Region { get; set; }
public string AccessKey { get; set; }
public string SecretKey { get; set; }
Expand All @@ -15,6 +16,7 @@ public static MinIoConfiguration FromConfiguration(IConfiguration configuration)
=> new()
{
Endpoint = configuration["minIo:endpoint"],
BaseUrl = configuration["minIo:baseUrl"] ?? configuration["minIo:endpoint"],
Region = configuration["minIo:region"] ?? "us-east-1",
AccessKey = configuration["minIo:accessKey"],
SecretKey = configuration["minIo:secretKey"],
Expand Down
4 changes: 2 additions & 2 deletions src/Eurofurence.App.Server.Services/Images/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public async Task<ImageRecord> InsertImageAsync(string internalReference, Stream
{
Id = guid,
InternalFileName = fileName,
Url = $"{_minIoClient.Config.Endpoint}/{_minIoConfiguration.Bucket}/{fileName}",
Url = $"{_minIoConfiguration.BaseUrl ?? _minIoClient.Config.BaseUrl}/{_minIoConfiguration.Bucket}/{fileName}",
InternalReference = internalReference,
IsDeleted = 0,
MimeType = imageFormat?.DefaultMimeType,
Expand Down Expand Up @@ -167,7 +167,7 @@ await UploadFileToMinIoAsync(_minIoConfiguration.Bucket, existingRecord.Internal
imageFormat?.DefaultMimeType, stream);

existingRecord.InternalFileName = fileName;
existingRecord.Url = $"{_minIoClient.Config.Endpoint}/{_minIoConfiguration.Bucket}/{fileName}";
existingRecord.Url = $"{_minIoConfiguration.BaseUrl ?? _minIoClient.Config.BaseUrl}/{_minIoConfiguration.Bucket}/{fileName}";
existingRecord.InternalReference = internalReference;
existingRecord.MimeType = imageFormat?.DefaultMimeType;
existingRecord.Width = image.Width;
Expand Down
5 changes: 3 additions & 2 deletions src/Eurofurence.App.Server.Web/appsettings.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"baseUrl": "",
"appIdITunes": 0,
"appIdPlay": "",
"workingDirectory": "/tmp/workingDir" // Working directory to store temporary data, e.g. the dealers export file
"workingDirectory": "/tmp/workingDir"
},
"logLevel": 1,
"auditLog": "/tmp/audit.log",
Expand Down Expand Up @@ -109,10 +109,11 @@
"url": ""
},
"events": {
"url": "" // URL to statically hosted events csv export file
"url": ""
},
"minIo": {
"endpoint": "minio:9000",
"baseUrl": "http://127.0.0.1:9000",
"region": "us-east-1",
"accessKey": "minioAccessKey",
"secretKey": "minioVerySecretKey",
Expand Down

0 comments on commit 56940cb

Please sign in to comment.