Class StorageKeys
java.lang.Object
io.leandev.appfuse.file.StorageKeys
儲存識別碼驗證
所有 FileStorage 實作在組出實體路徑或 object key 前,以此驗證 partition 與檔案識別碼,
確保呼叫端傳入的值不能離開所屬儲存區,也不能與其他 partition 的 key 重疊。
規則
- partition:單一區段,不可為空白、
.、..,不可含/、\、:或控制字元 - fileId/tempId:以
/分隔的相對路徑,每個區段遵循 partition 規則; 不可以/開頭或結尾,不可有空區段
FileIdGenerator 產生的 yyyy-MM-dd/HH/uuid 與各 backend 的 tempId 皆符合規則。
驗證失敗拋出 InvalidStorageKeyException,訊息不含原始值。
-
Method Summary
-
Method Details
-
requirePartition
驗證 partition- Parameters:
partition- 分區名稱- Returns:
- 原值
- Throws:
InvalidStorageKeyException- 不合法時
-
requireId
驗證 fileId 或 tempId- Parameters:
id- 檔案識別碼- Returns:
- 原值
- Throws:
InvalidStorageKeyException- 不合法時
-