mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 07:22:34 +00:00
extract text from pdf and image
This commit is contained in:
@@ -106,6 +106,24 @@ export const MetadataAIOperationsProvider = ({
|
||||
});
|
||||
}, [repoID]);
|
||||
|
||||
|
||||
const extractText = useCallback(({ parentDir, fileName }, { success_callback, fail_callback } = {}) => {
|
||||
const filePath = Utils.joinPath(parentDir, fileName);
|
||||
const inProgressToaster = toaster.notifyInProgress(gettext('Extracting text by AI...'), { duration: null });
|
||||
metadataAPI.extractText(repoID, filePath).then(res => {
|
||||
console.log(res)
|
||||
const extractedText = res?.data?.text || res.data.text || '';
|
||||
inProgressToaster.close();
|
||||
success_callback && success_callback({ parentDir, fileName, extractedText });
|
||||
}).catch(error => {
|
||||
inProgressToaster.close();
|
||||
const errorMessage = gettext('Failed to extract text');
|
||||
toaster.danger(errorMessage);
|
||||
fail_callback && fail_callback();
|
||||
});
|
||||
}, [repoID]);
|
||||
|
||||
|
||||
return (
|
||||
<MetadataAIOperationsContext.Provider value={{
|
||||
enableMetadata,
|
||||
@@ -119,6 +137,7 @@ export const MetadataAIOperationsProvider = ({
|
||||
extractFilesDetails,
|
||||
extractFileDetails,
|
||||
faceRecognition,
|
||||
extractText
|
||||
}}>
|
||||
{children}
|
||||
</MetadataAIOperationsContext.Provider>
|
||||
|
Reference in New Issue
Block a user