feat: извлекаю текст PDF через новый API
This commit is contained in:
+8
@@ -240,6 +240,7 @@ export function useKpProcessing(
|
|||||||
patchFile(entry.localId, { spId, status: 'extracting' });
|
patchFile(entry.localId, { spId, status: 'extracting' });
|
||||||
|
|
||||||
const isWord = /\.(doc|docx|xls|xlsx)$/i.test(entry.file.name);
|
const isWord = /\.(doc|docx|xls|xlsx)$/i.test(entry.file.name);
|
||||||
|
const isPdf = /\.pdf$/i.test(entry.file.name);
|
||||||
if (isWord) {
|
if (isWord) {
|
||||||
try {
|
try {
|
||||||
await service.extractWordText(spId);
|
await service.extractWordText(spId);
|
||||||
@@ -247,6 +248,13 @@ export function useKpProcessing(
|
|||||||
patchFile(entry.localId, { status: 'error', error: `Ошибка извлечения текста Word: ${(err as Error).message}` });
|
patchFile(entry.localId, { status: 'error', error: `Ошибка извлечения текста Word: ${(err as Error).message}` });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else if (isPdf) {
|
||||||
|
try {
|
||||||
|
await service.extractPDFText(spId);
|
||||||
|
} catch (err) {
|
||||||
|
patchFile(entry.localId, { status: 'error', error: `Ошибка извлечения текста PDF: ${(err as Error).message}` });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pollSyntex(entry.localId, spId, name, 0).catch(err => {
|
pollSyntex(entry.localId, spId, name, 0).catch(err => {
|
||||||
|
|||||||
@@ -1406,6 +1406,24 @@ export class CtService {
|
|||||||
throw new Error(`Ошибка извлечения текста Word: ${res.status}`);
|
throw new Error(`Ошибка извлечения текста Word: ${res.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async extractPDFText(itemId: number): Promise<void> {
|
||||||
|
const token = await this._getApiToken();
|
||||||
|
const res = await fetch(`${EXTERNAL_API}/Document/extractPDFText`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
siteUrl: this.baseUrl,
|
||||||
|
libraryName: KP_LIBRARY_DISPLAY_NAME,
|
||||||
|
itemId: String(itemId),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
if (!res.ok)
|
||||||
|
throw new Error(`Ошибка извлечения текста PDF: ${res.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
async triggerFlow(
|
async triggerFlow(
|
||||||
fileName: string,
|
fileName: string,
|
||||||
fileId: number,
|
fileId: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user