Skip to content

Commit

Permalink
feat: support object lifecycle with gcs cdn (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Feb 28, 2025
1 parent 2042021 commit f68a791
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions projects/fal/src/fal/toolkit/file/providers/fal.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def set(self, value: VariableType) -> None:
@dataclass
class FalFileRepositoryBase(FileRepository):
@retry(max_retries=3, base_delay=1, backoff_type="exponential", jitter=True)
def _save(self, file: FileData, storage_type: str) -> str:
def _save(
self, file: FileData, storage_type: str, headers: dict[str, str] | None = None
) -> str:
key_creds = key_credentials()
if not key_creds:
raise FileUploadException("FAL_KEY must be set")
Expand All @@ -135,6 +137,7 @@ def _save(self, file: FileData, storage_type: str) -> str:
"Authorization": f"Key {key_id}:{key_secret}",
"Accept": "application/json",
"Content-Type": "application/json",
**(headers or {}),
}

grpc_host = os.environ.get("FAL_HOST", "api.alpha.fal.ai")
Expand Down Expand Up @@ -193,7 +196,11 @@ def save(
multipart_max_concurrency: int | None = None,
object_lifecycle_preference: dict[str, str] | None = None,
) -> str:
return self._save(file, "gcs")
headers = {}
if object_lifecycle_preference:
headers["X-Fal-Object-Lifecycle"] = json.dumps(object_lifecycle_preference)

return self._save(file, "gcs", headers=headers)


class MultipartUpload:
Expand Down

0 comments on commit f68a791

Please sign in to comment.