mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: upload file in FileManager #345 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
import { IFileListRequestBody } from '@/interfaces/request/file-manager';
|
||||
import {
|
||||
IConnectRequestBody,
|
||||
IFileListRequestBody,
|
||||
} from '@/interfaces/request/file-manager';
|
||||
import { UploadFile } from 'antd';
|
||||
import { useCallback } from 'react';
|
||||
import { useDispatch, useSelector } from 'umi';
|
||||
|
||||
@ -94,3 +98,47 @@ export const useSelectParentFolderList = () => {
|
||||
);
|
||||
return parentFolderList.toReversed();
|
||||
};
|
||||
|
||||
export const useUploadFile = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const uploadFile = useCallback(
|
||||
(file: UploadFile, parentId: string, path: string) => {
|
||||
try {
|
||||
return dispatch<any>({
|
||||
type: 'fileManager/uploadFile',
|
||||
payload: {
|
||||
file,
|
||||
parentId,
|
||||
path,
|
||||
},
|
||||
});
|
||||
} catch (errorInfo) {
|
||||
console.log('Failed:', errorInfo);
|
||||
}
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return uploadFile;
|
||||
};
|
||||
|
||||
export const useConnectToKnowledge = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const uploadFile = useCallback(
|
||||
(payload: IConnectRequestBody) => {
|
||||
try {
|
||||
return dispatch<any>({
|
||||
type: 'fileManager/connectFileToKnowledge',
|
||||
payload,
|
||||
});
|
||||
} catch (errorInfo) {
|
||||
console.log('Failed:', errorInfo);
|
||||
}
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
return uploadFile;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user