This commit is contained in:
HugoCasa
2025-04-11 15:00:16 +02:00
parent 5409b280c3
commit 62b0925db9
19 changed files with 503 additions and 370 deletions

View File

@@ -586,9 +586,12 @@ class Windmill:
raise Exception("Could not write file to S3") from e
return S3Object(s3=response["file_key"])
def sign_s3_objects(self, s3_objects: list[S3Object]) -> list[str]:
def sign_s3_objects(self, s3_objects: list[S3Object]) -> list[S3Object]:
return self.post(f"/w/{self.workspace}/apps/sign_s3_objects", json={"s3_objects": s3_objects}).json()
def sign_s3_object(self, s3_object: S3Object) -> S3Object:
return self.post(f"/w/{self.workspace}/apps/sign_s3_objects", json={"s3_objects": [s3_object]}).json()[0]
def __boto3_connection_settings(self, s3_resource) -> Boto3ConnectionSettings:
endpoint_url_prefix = "https://" if s3_resource["useSSL"] else "http://"
return Boto3ConnectionSettings(
@@ -978,7 +981,7 @@ def write_s3_file(
@init_global_client
def sign_s3_objects(s3_objects: list[S3Object]) -> list[str]:
def sign_s3_objects(s3_objects: list[S3Object]) -> list[S3Object]:
"""
Sign S3 objects to be used by anonymous users in public apps
Returns a list of signed s3 tokens
@@ -986,6 +989,15 @@ def sign_s3_objects(s3_objects: list[S3Object]) -> list[str]:
return _client.sign_s3_objects(s3_objects)
@init_global_client
def sign_s3_object(s3_object: S3Object) -> S3Object:
"""
Sign S3 object to be used by anonymous users in public apps
Returns a signed s3 object
"""
return _client.sign_s3_object(s3_object)
@init_global_client
def whoami() -> dict:
"""

View File

@@ -1,6 +1,7 @@
class S3Object(dict):
s3: str
storage: str | None
presigned: str | None
def __getattr__(self, attr):
return self[attr]