Skip to content

Commit 9bfdedf

Browse files
fix: file name during parsing
1 parent ac6601c commit 9bfdedf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

hrflow/profile/parsing.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def add_file(
2727
source_key,
2828
key=None,
2929
profile_file=None,
30+
profile_file_name=None,
3031
profile_content_type=None,
3132
reference=None,
3233
created_at=None,
@@ -47,6 +48,8 @@ def add_file(
4748
source_key
4849
profile_file: <binary>
4950
profile binary
51+
profile_file_name: <string>
52+
file name
5053
profile_content_type <string>
5154
file content type
5255
reference: <string> (default to None)
@@ -85,8 +88,14 @@ def add_file(
8588
"sync_parsing_indexing": sync_parsing_indexing,
8689
"webhook_parsing_sending": webhook_parsing_sending,
8790
}
91+
92+
if profile_file_name is None:
93+
file_payload = {"file": profile_file}
94+
else:
95+
file_payload = {"file": (profile_file_name, profile_file)}
96+
8897
response = self.client.post(
89-
"profile/parsing/file", data=payload, files={"file": profile_file}
98+
"profile/parsing/file", data=payload, files=file_payload
9099
)
91100
return validate_response(response)
92101

@@ -136,12 +145,14 @@ def add_folder(
136145
if show_progress:
137146
files_to_send = tqdm(files_to_send, "Parsing")
138147
for file_path in files_to_send:
148+
filename = os.path.basename(file_path)
139149
try:
140150
with open(file_path, "rb") as f:
141151
profile_file = f.read()
142152
resp = self.add_file(
143153
source_key=source_key,
144154
profile_file=profile_file,
155+
profile_file_name=filename,
145156
created_at=created_at,
146157
sync_parsing=sync_parsing,
147158
**kwargs,

0 commit comments

Comments
 (0)