Skip to content

Commit 87f0737

Browse files
committed
[fix] File Name in File Preview & Picker components
1 parent db57559 commit 87f0737

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobx-restful-table",
3-
"version": "2.7.5",
3+
"version": "2.7.6",
44
"license": "LGPL-3.0",
55
"author": "shiy2008@gmail.com",
66
"description": "A Pagination Table & Scroll List component suite for CRUD operation, which is based on MobX RESTful & React.",

‎source/FilePicker.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { computed, observable } from 'mobx';
22
import { observer } from 'mobx-react';
33
import { FormComponent, FormComponentProps, reaction } from 'mobx-react-helper';
44
import { Button, ButtonGroup } from 'react-bootstrap';
5-
import { blobOf } from 'web-utility';
5+
import { blobOf, fileNameOf } from 'web-utility';
66

77
import { FilePreview, FilePreviewProps } from './FilePreview';
88
import * as styles from './FilePicker.module.less';
@@ -40,7 +40,7 @@ export class FilePicker extends FormComponent<FilePickerProps> {
4040
if (typeof data === 'string')
4141
try {
4242
const blob = await blobOf(data),
43-
name = data.split('/').at(-1) || '';
43+
name = fileNameOf(data);
4444
const file = new File([blob], name, { type: blob.type });
4545

4646
blobCache.set(file, data);

‎source/ImagePreview.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { observable } from 'mobx';
55
import { observer } from 'mobx-react';
66
import { ObservedComponent, reaction } from 'mobx-react-helper';
77
import { Image, ImageProps, Modal, Spinner } from 'react-bootstrap';
8+
import { fileNameOf } from 'web-utility';
89

910
export type ImagePreviewProps = ImageProps;
1011

@@ -103,7 +104,7 @@ export class ImagePreview extends ObservedComponent<ImagePreviewProps> {
103104
as="a"
104105
href={loadedPath}
105106
target="_blank"
106-
download={loadedPath.split('/').pop()}
107+
download={fileNameOf(loadedPath)}
107108
>
108109
{loadedPath}
109110
</Modal.Footer>

0 commit comments

Comments
 (0)