mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 23:27:37 +00:00
fix(file-browser): reuse download-link API url for copy name and path
This commit is contained in:
@@ -9,7 +9,6 @@ import { AssetService } from './asset'
|
||||
vi.mock('@shumai/core/src/s3/s3', () => ({
|
||||
s3Service: {
|
||||
presign: vi.fn().mockResolvedValue('http://mock-s3-url'),
|
||||
getAbsolutePathOrUrl: vi.fn().mockResolvedValue('http://mock-s3-url'),
|
||||
putObject: vi.fn().mockResolvedValue(undefined),
|
||||
deleteObject: vi.fn().mockResolvedValue(1),
|
||||
deletePrefix: vi.fn().mockResolvedValue(1),
|
||||
|
||||
@@ -1969,7 +1969,7 @@ export class AssetService {
|
||||
const key = file.storageKeyId ? storageKeyMap.get(file.storageKeyId) : null
|
||||
if (!key) return null
|
||||
|
||||
const url = await s3Service.getAbsolutePathOrUrl(process.env.S3_BUCKET || 'shumai', key)
|
||||
const url = await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET', true)
|
||||
|
||||
return {
|
||||
id: file.id,
|
||||
|
||||
@@ -55,7 +55,6 @@ export interface S3Service {
|
||||
uploadFile(filePath: string, contentType: string): Promise<string>
|
||||
uploadFileToKey(filePath: string, key: string, contentType: string): Promise<void>
|
||||
presign(bucket: string, key: string, method: string, download?: boolean): Promise<string>
|
||||
getAbsolutePathOrUrl(bucket: string, key: string): Promise<string>
|
||||
}
|
||||
|
||||
export class S3StorageService implements S3Service {
|
||||
@@ -231,10 +230,6 @@ export class S3StorageService implements S3Service {
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
async getAbsolutePathOrUrl(bucket: string, key: string): Promise<string> {
|
||||
return this.presign(bucket, key, 'GET', true)
|
||||
}
|
||||
}
|
||||
|
||||
export class LocalStorageService implements S3Service {
|
||||
@@ -446,10 +441,6 @@ export class LocalStorageService implements S3Service {
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
async getAbsolutePathOrUrl(bucket: string, key: string): Promise<string> {
|
||||
return this.getFilePath(bucket, key)
|
||||
}
|
||||
}
|
||||
|
||||
const storageBackend = process.env.STORAGE_BACKEND || 'local'
|
||||
|
||||
Reference in New Issue
Block a user