Skip to content

Commit a852353

Browse files
committed
feat(storage): 添加onedrive支持断点续传的统一前端分块上传
- 添加 `per_part_url` (S3) 和 `single_session` (OneDrive) 策略 - 通过基于指纹的查找为两种策略启用服务器端断点续传 - 将后端和前端版本升级至 1.3.0
1 parent 6309299 commit a852353

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

backend/src/storage/factory/StorageFactory.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ function validateDriverContract(driver, entryMeta, storageType) {
8585

8686
const driverType = typeof driver.getType === "function" ? driver.getType() : driver.type;
8787
const rawCaps =
88-
typeof driver.getCapabilities === "function"
89-
? driver.getCapabilities() || []
90-
: Array.isArray(driver.capabilities)
91-
? driver.capabilities
92-
: [];
88+
typeof driver.getCapabilities === "function"
89+
? driver.getCapabilities() || []
90+
: Array.isArray(driver.capabilities)
91+
? driver.capabilities
92+
: [];
9393

9494
const detectedCapabilities = getObjectCapabilities(driver);
9595
const driverCapabilities = Array.from(new Set(rawCaps.length ? rawCaps : detectedCapabilities));
@@ -156,18 +156,18 @@ export class StorageFactory {
156156

157157
// 注册驱动
158158
static registerDriver(
159-
type,
160-
{
161-
ctor,
162-
tester = null,
163-
displayName = null,
164-
validate = null,
165-
capabilities = [],
166-
ui = null,
167-
configSchema = null,
168-
providerOptions = null,
169-
configProjector = null,
170-
} = {},
159+
type,
160+
{
161+
ctor,
162+
tester = null,
163+
displayName = null,
164+
validate = null,
165+
capabilities = [],
166+
ui = null,
167+
configSchema = null,
168+
providerOptions = null,
169+
configProjector = null,
170+
} = {},
171171
) {
172172
if (!type || !ctor) throw new ValidationError("registerDriver 需要提供 type 和 ctor");
173173
registry.set(type, {
@@ -471,7 +471,7 @@ StorageFactory.registerDriver(StorageFactory.SUPPORTED_TYPES.S3, {
471471
i18nKey: "admin.storage.type.s3",
472472
badgeTheme: "s3",
473473
},
474-
configProjector(cfg, { withSecrets = false } = {}) {
474+
configProjector(cfg, { withSecrets = false } = {}) {
475475
const projected = {
476476
// 通用字段
477477
default_folder: cfg?.default_folder,
@@ -888,14 +888,7 @@ StorageFactory.registerDriver(StorageFactory.SUPPORTED_TYPES.ONEDRIVE, {
888888
tester: oneDriveTestConnection,
889889
displayName: "OneDrive 存储",
890890
validate: (cfg) => StorageFactory._validateOneDriveConfig(cfg),
891-
capabilities: [
892-
CAPABILITIES.READER,
893-
CAPABILITIES.WRITER,
894-
CAPABILITIES.ATOMIC,
895-
CAPABILITIES.PROXY,
896-
CAPABILITIES.SEARCH,
897-
CAPABILITIES.DIRECT_LINK,
898-
],
891+
capabilities: [CAPABILITIES.READER, CAPABILITIES.WRITER, CAPABILITIES.ATOMIC, CAPABILITIES.PROXY, CAPABILITIES.SEARCH, CAPABILITIES.DIRECT_LINK],
899892
ui: {
900893
icon: "storage-onedrive",
901894
i18nKey: "admin.storage.type.onedrive",
@@ -906,6 +899,7 @@ StorageFactory.registerDriver(StorageFactory.SUPPORTED_TYPES.ONEDRIVE, {
906899
// 通用字段
907900
default_folder: cfg?.default_folder ?? cfg?.root_folder ?? "",
908901
custom_host: cfg?.custom_host,
902+
url_proxy: cfg?.url_proxy,
909903
signature_expires_in: cfg?.signature_expires_in,
910904
total_storage_bytes: cfg?.total_storage_bytes,
911905
// OneDrive 专用字段
@@ -984,6 +978,18 @@ StorageFactory.registerDriver(StorageFactory.SUPPORTED_TYPES.ONEDRIVE, {
984978
descriptionKey: "admin.storage.description.onedrive.root_folder",
985979
},
986980
},
981+
{
982+
name: "url_proxy",
983+
type: "string",
984+
required: false,
985+
labelKey: "admin.storage.fields.url_proxy",
986+
validation: { rule: "url" },
987+
ui: {
988+
fullWidth: true,
989+
placeholderKey: "admin.storage.placeholder.url_proxy",
990+
descriptionKey: "admin.storage.description.url_proxy",
991+
},
992+
},
987993
{
988994
name: "token_renew_endpoint",
989995
type: "string",
@@ -1036,7 +1042,7 @@ StorageFactory.registerDriver(StorageFactory.SUPPORTED_TYPES.ONEDRIVE, {
10361042
{
10371043
name: "advanced",
10381044
titleKey: "admin.storage.groups.advanced",
1039-
fields: ["redirect_uri", ["token_renew_endpoint", "use_online_api"]],
1045+
fields: ["redirect_uri", ["token_renew_endpoint", "use_online_api"], "url_proxy"],
10401046
},
10411047
],
10421048
summaryFields: ["region", "default_folder", "use_online_api"],

0 commit comments

Comments
 (0)