|
16 | 16 | ) |
17 | 17 | from models_library.api_schemas_storage.storage_schemas import ( |
18 | 18 | FileUploadSchema, |
| 19 | + LinkType, |
19 | 20 | PresignedLink, |
20 | 21 | ) |
21 | 22 | from models_library.basic_types import SHA256Str |
22 | 23 | from models_library.generics import Envelope |
23 | 24 | from models_library.rest_pagination import PageLimitInt, PageOffsetInt |
24 | 25 | from pydantic import AnyUrl |
25 | 26 | from settings_library.tracing import TracingSettings |
| 27 | +from simcore_service_api_server.models.schemas.files import UserFile |
| 28 | +from simcore_service_api_server.models.schemas.jobs import UserFileToProgramJob |
26 | 29 | from starlette.datastructures import URL |
27 | 30 |
|
28 | 31 | from ..core.settings import StorageSettings |
@@ -157,15 +160,22 @@ async def delete_file(self, *, user_id: int, quoted_storage_file_id: str) -> Non |
157 | 160 | response.raise_for_status() |
158 | 161 |
|
159 | 162 | @_exception_mapper(http_status_map={}) |
160 | | - async def get_upload_links( |
161 | | - self, *, user_id: int, file_id: UUID, file_name: str |
| 163 | + async def get_file_upload_links( |
| 164 | + self, *, user_id: int, file: File, client_file: UserFileToProgramJob | UserFile |
162 | 165 | ) -> FileUploadSchema: |
163 | | - object_path = urllib.parse.quote_plus(f"api/{file_id}/{file_name}") |
| 166 | + |
| 167 | + query_params = { |
| 168 | + "user_id": f"{user_id}", |
| 169 | + "link_type": LinkType.PRESIGNED.value, |
| 170 | + "file_size": int(client_file.filesize), |
| 171 | + "is_directory": "false", |
| 172 | + "sha256_checksum": client_file.sha256_checksum, |
| 173 | + } |
164 | 174 |
|
165 | 175 | # complete_upload_file |
166 | 176 | response = await self.client.put( |
167 | | - f"/locations/{self.SIMCORE_S3_ID}/files/{object_path}", |
168 | | - params={"user_id": user_id, "file_size": 0}, |
| 177 | + f"/locations/{self.SIMCORE_S3_ID}/files/{file.storage_file_id}", |
| 178 | + params=query_params, |
169 | 179 | ) |
170 | 180 | response.raise_for_status() |
171 | 181 |
|
|
0 commit comments