Skip to content

Commit 03890bc

Browse files
authored
fix: set fallback file name while import documents from other api server (#6372)
* fix: deps * fix: set fallback file name while import documents from other api server
1 parent cfded3a commit 03890bc

2 files changed

Lines changed: 243 additions & 50 deletions

File tree

packages/service/core/dataset/apiDataset/custom/api.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { readFileRawTextByUrl } from '../../read';
1111
import { type ParentIdType } from '@fastgpt/global/common/parentFolder/type';
1212
import { type RequireOnlyOne } from '@fastgpt/global/common/type/utils';
1313
import { getS3RawTextSource } from '../../../../common/s3/sources/rawText';
14+
import { getNanoid } from '@fastgpt/global/common/string/tools';
1415

1516
type ResponseDataType = {
1617
success: boolean;
@@ -176,15 +177,17 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
176177
getFormatText: true
177178
});
178179

180+
const sourceName = title || getNanoid();
181+
179182
getS3RawTextSource().addRawTextBuffer({
180183
sourceId: previewUrl,
181-
sourceName: title || '',
184+
sourceName,
182185
text: rawText,
183186
customPdfParse
184187
});
185188

186189
return {
187-
title,
190+
title: sourceName,
188191
rawText
189192
};
190193
}

0 commit comments

Comments
 (0)