Spaces:
Sleeping
Sleeping
Update extract_and_store_supabase.py
Browse files
extract_and_store_supabase.py
CHANGED
@@ -38,18 +38,26 @@ async def extract_structure_store_message(filename:str,user_id:str):
|
|
38 |
filename
|
39 |
)
|
40 |
base64_data = urlsafe_b64encode(response).decode('utf-8')
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
-
}
|
49 |
|
50 |
access_token = get_access_token_v1()
|
51 |
print(access_token)
|
52 |
-
|
53 |
headers = {
|
54 |
'Authorization': f'Bearer {access_token}',
|
55 |
'Content-Type': 'application/json; charset=utf-8'
|
|
|
38 |
filename
|
39 |
)
|
40 |
base64_data = urlsafe_b64encode(response).decode('utf-8')
|
41 |
+
if attachment_extension == 'pdf':
|
42 |
+
payload = {
|
43 |
+
"skipHumanReview": True,
|
44 |
+
"rawDocument": {
|
45 |
+
"mimeType": f"application/{attachment_extension}",
|
46 |
+
"content": base64_data
|
47 |
+
}
|
48 |
+
}
|
49 |
+
elif attachment_extension == 'jpg' or attachment_extension == 'png':
|
50 |
+
payload = {
|
51 |
+
"skipHumanReview": True,
|
52 |
+
"rawDocument": {
|
53 |
+
"mimeType": f"image/{attachment_extension}",
|
54 |
+
"content": base64_data
|
55 |
+
}
|
56 |
}
|
|
|
57 |
|
58 |
access_token = get_access_token_v1()
|
59 |
print(access_token)
|
60 |
+
|
61 |
headers = {
|
62 |
'Authorization': f'Bearer {access_token}',
|
63 |
'Content-Type': 'application/json; charset=utf-8'
|