17
17
from ragna .deploy import Config
18
18
19
19
20
+ class DocumentUploadParameters (BaseModel ):
21
+ method : str
22
+ url : str
23
+ data : dict
24
+
25
+
20
26
class Document (RequirementsMixin , abc .ABC ):
21
27
"""Abstract base class for all documents."""
22
28
@@ -59,7 +65,7 @@ def get_handler(name: str) -> DocumentHandler:
59
65
@abc .abstractmethod
60
66
async def get_upload_info (
61
67
cls , * , config : Config , user : str , id : uuid .UUID , name : str
62
- ) -> tuple [str , dict [str , Any ], dict [ str , Any ] ]:
68
+ ) -> tuple [dict [str , Any ], DocumentUploadParameters ]:
63
69
pass
64
70
65
71
@abc .abstractmethod
@@ -136,7 +142,7 @@ def read(self) -> bytes:
136
142
@classmethod
137
143
async def get_upload_info (
138
144
cls , * , config : Config , user : str , id : uuid .UUID , name : str
139
- ) -> tuple [str , dict [str , Any ], dict [ str , Any ] ]:
145
+ ) -> tuple [dict [str , Any ], DocumentUploadParameters ]:
140
146
url = f"{ config .api .url } /document"
141
147
data = {
142
148
"token" : jwt .encode (
@@ -150,7 +156,7 @@ async def get_upload_info(
150
156
)
151
157
}
152
158
metadata = {"path" : str (config .local_cache_root / "documents" / str (id ))}
153
- return url , data , metadata
159
+ return metadata , DocumentUploadParameters ( method = "PUT" , url = url , data = data )
154
160
155
161
@classmethod
156
162
def decode_upload_token (cls , token : str ) -> tuple [str , uuid .UUID ]:
0 commit comments