Skip to content

Commit 85a0081

Browse files
committed
start migrating to normal storage client
1 parent 7e65758 commit 85a0081

File tree

1 file changed

+15
-5
lines changed
  • services/api-server/src/simcore_service_api_server/services_http

1 file changed

+15
-5
lines changed

services/api-server/src/simcore_service_api_server/services_http/storage.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616
)
1717
from models_library.api_schemas_storage.storage_schemas import (
1818
FileUploadSchema,
19+
LinkType,
1920
PresignedLink,
2021
)
2122
from models_library.basic_types import SHA256Str
2223
from models_library.generics import Envelope
2324
from models_library.rest_pagination import PageLimitInt, PageOffsetInt
2425
from pydantic import AnyUrl
2526
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
2629
from starlette.datastructures import URL
2730

2831
from ..core.settings import StorageSettings
@@ -157,15 +160,22 @@ async def delete_file(self, *, user_id: int, quoted_storage_file_id: str) -> Non
157160
response.raise_for_status()
158161

159162
@_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
162165
) -> 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+
}
164174

165175
# complete_upload_file
166176
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,
169179
)
170180
response.raise_for_status()
171181

0 commit comments

Comments
 (0)