支持 S3 兼容对象存储 (#336)
* feat(storage): 支持 S3 对象存储 * fix(storage): 补齐 S3 对象文件后缀
This commit is contained in:
@@ -5,6 +5,7 @@ import type { CanvasDrawingEngineSetting } from "@/lib/canvas/canvas-drawing-eng
|
||||
import type { FeatureAvailability } from "@/stores/use-user-store";
|
||||
import { apiClient, request } from "@/services/api/request";
|
||||
import type { PublicLogicalModel } from "@/services/api/logical-models";
|
||||
import type { OSSConnectionTestInput, OSSConnectionTestResult, OSSProvider, S3Preset } from "@/lib/oss-settings";
|
||||
|
||||
const api = apiClient;
|
||||
|
||||
@@ -257,7 +258,8 @@ export type UserPromptPreference = {
|
||||
|
||||
export type AdminOSSSetting = {
|
||||
enabled: boolean;
|
||||
provider: "aliyun" | "tencent" | "qiniu";
|
||||
provider: OSSProvider;
|
||||
s3Preset: S3Preset;
|
||||
region: string;
|
||||
endpoint: string;
|
||||
cdnBaseUrl: string;
|
||||
@@ -265,8 +267,16 @@ export type AdminOSSSetting = {
|
||||
accessKeyId: string;
|
||||
accessKeySecret?: string;
|
||||
hasAccessKeySecret: boolean;
|
||||
sessionToken?: string;
|
||||
hasSessionToken: boolean;
|
||||
pathStyle: boolean;
|
||||
allowUserS3: boolean;
|
||||
publicBaseUrl: string;
|
||||
pathPrefix: string;
|
||||
testedAt?: string;
|
||||
testedDigest?: string;
|
||||
historyCount?: number;
|
||||
referencedResourceCount?: number;
|
||||
updatedBy?: string;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
@@ -501,6 +511,10 @@ export function updateAdminOSSSetting(input: Partial<AdminOSSSetting>) {
|
||||
return request<{ setting: AdminOSSSetting }>(api.patch("/admin/settings/oss", input));
|
||||
}
|
||||
|
||||
export function testAdminOSSConnection(input: OSSConnectionTestInput) {
|
||||
return request<OSSConnectionTestResult>(api.post("/admin/settings/oss/test", input));
|
||||
}
|
||||
|
||||
export function getAdminArkPrivateAssetSetting() {
|
||||
return request<{ setting: AdminArkPrivateAssetSetting }>(api.get("/admin/settings/ark-private-assets"));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { getActiveUserScope } from "@/lib/user-scope";
|
||||
import axios from "axios";
|
||||
import { apiBaseURL, apiClient, request, type BackendEnvelope } from "@/services/api/request";
|
||||
import type { OSSConnectionTestInput, OSSConnectionTestResult, OSSProvider, S3Preset } from "@/lib/oss-settings";
|
||||
|
||||
export type RemoteResource = {
|
||||
id: string;
|
||||
@@ -25,20 +26,30 @@ export type RemoteResource = {
|
||||
|
||||
export type UserOSSSetting = {
|
||||
enabled: boolean;
|
||||
provider: "aliyun" | "tencent" | "qiniu";
|
||||
provider: OSSProvider;
|
||||
s3Preset: S3Preset;
|
||||
region: string;
|
||||
endpoint: string;
|
||||
cdnBaseUrl: string;
|
||||
bucket: string;
|
||||
accessKeyId: string;
|
||||
hasAccessKeySecret: boolean;
|
||||
sessionToken?: string;
|
||||
hasSessionToken: boolean;
|
||||
pathStyle: boolean;
|
||||
allowUserS3: boolean;
|
||||
publicBaseUrl: string;
|
||||
pathPrefix: string;
|
||||
testedAt?: string;
|
||||
testedDigest?: string;
|
||||
historyCount?: number;
|
||||
referencedResourceCount?: number;
|
||||
updatedAt?: string;
|
||||
};
|
||||
|
||||
export type UserOSSSettingInput = Pick<UserOSSSetting, "enabled" | "provider" | "region" | "endpoint" | "cdnBaseUrl" | "bucket" | "accessKeyId" | "pathPrefix"> & {
|
||||
export type UserOSSSettingInput = Pick<UserOSSSetting, "enabled" | "provider" | "s3Preset" | "region" | "endpoint" | "cdnBaseUrl" | "bucket" | "accessKeyId" | "pathPrefix" | "pathStyle"> & {
|
||||
accessKeySecret?: string;
|
||||
sessionToken?: string;
|
||||
};
|
||||
|
||||
export type AccountFileStorageUsage = {
|
||||
@@ -68,6 +79,10 @@ export function updateUserOSSSetting(input: UserOSSSettingInput) {
|
||||
return request<{ setting: UserOSSSetting }>(api.patch("/settings/oss", input));
|
||||
}
|
||||
|
||||
export function testUserOSSConnection(input: OSSConnectionTestInput) {
|
||||
return request<OSSConnectionTestResult>(api.post("/settings/oss/test", input));
|
||||
}
|
||||
|
||||
export async function getAccountFileStorageUsage() {
|
||||
const data = await request<{ usage: AccountFileStorageUsage }>(api.get("/resources/storage-usage"));
|
||||
return data.usage;
|
||||
|
||||
Reference in New Issue
Block a user