Skip to content

Commit 2aeec1d

Browse files
Wojciech KrysiakWojciech Krysiak
authored andcommitted
fix: fixing wrong '/' for local adapter the right way
1 parent 685fdf1 commit 2aeec1d

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/features/upload-file/components/file.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@ type Props = ShowPropertyProps & {
1212

1313
const File: FC<Props> = ({ width, record, property }) => {
1414
const { custom } = property as unknown as { custom: PropertyCustom }
15-
const { provider } = custom
1615

17-
let path = record?.params[custom.filePathProperty]
16+
const path = record?.params[custom.filePathProperty]
1817
if (!path) {
1918
return null
2019
}
2120

22-
if (provider === 'local' && typeof path === 'string' && !path.startsWith('/')) {
23-
// append / to the path when bucket is defined as a relative path
24-
// which is in the case of Local adapter when bucket is 'public'
25-
path = `/${path}`
26-
}
27-
2821
const name = custom.fileNameProperty
2922
? record?.params[custom.fileNameProperty]
3023
: record?.params[custom.keyProperty]

src/features/upload-file/providers/local-provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ export default class LocalProvider extends BaseAdapter {
3636

3737
// eslint-disable-next-line class-methods-use-this
3838
public path(key: string, bucket?: string): string {
39-
return path.join(bucket || this.bucket, key)
39+
return `/${path.join(bucket || this.bucket, key)}`
4040
}
4141
}

0 commit comments

Comments
 (0)