Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support object lifecycle with gcs cdn #434

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading