Support access with custom endpoint

This commit is contained in:
2025-12-27 15:50:26 +08:00
parent 6e1b67609a
commit fc61235d0c
2 changed files with 4 additions and 2 deletions

View File

@@ -145,9 +145,7 @@ public class FileController(
private ActionResult? TryProxyRedirect(SnCloudFile file, RemoteStorageConfig dest, string fileName) private ActionResult? TryProxyRedirect(SnCloudFile file, RemoteStorageConfig dest, string fileName)
{ {
if (dest.ImageProxy is not null && (file.MimeType?.StartsWith("image/") ?? false)) if (dest.ImageProxy is not null && (file.MimeType?.StartsWith("image/") ?? false))
{
return Redirect(BuildProxyUrl(dest.ImageProxy, fileName)); return Redirect(BuildProxyUrl(dest.ImageProxy, fileName));
}
return dest.AccessProxy is not null ? Redirect(BuildProxyUrl(dest.AccessProxy, fileName)) : null; return dest.AccessProxy is not null ? Redirect(BuildProxyUrl(dest.AccessProxy, fileName)) : null;
} }
@@ -182,6 +180,9 @@ public class FileController(
.WithHeaders(headers) .WithHeaders(headers)
); );
if (dest.AccessEndpoint is not null)
openUrl = openUrl.Replace($"{dest.Endpoint}/{dest.Bucket}", dest.AccessEndpoint);
return Redirect(openUrl); return Redirect(openUrl);
} }

View File

@@ -9,6 +9,7 @@ public class RemoteStorageConfig
public string Region { get; set; } = string.Empty; public string Region { get; set; } = string.Empty;
public string Bucket { get; set; } = string.Empty; public string Bucket { get; set; } = string.Empty;
public string Endpoint { get; set; } = string.Empty; public string Endpoint { get; set; } = string.Empty;
public string? AccessEndpoint { get; set; }
public string SecretId { get; set; } = string.Empty; public string SecretId { get; set; } = string.Empty;
public string SecretKey { get; set; } = string.Empty; public string SecretKey { get; set; } = string.Empty;
public bool EnableSigned { get; set; } public bool EnableSigned { get; set; }