Skip to content

Commit

Permalink
feat: Offer presigned URL V3 CDN and mark token one as internal (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
chamini2 authored Nov 21, 2024
1 parent 0c8034e commit add676b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion projects/fal/src/fal/toolkit/file/providers/fal.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def save(
return self._save(file, "gcs")


@dataclass
class FalFileRepositoryV3(FalFileRepositoryBase):
def save(
self, file: FileData, object_lifecycle_preference: dict[str, str] | None = None
) -> str:
return self._save(file, "fal-cdn-v3")


class MultipartUpload:
MULTIPART_THRESHOLD = 100 * 1024 * 1024
MULTIPART_CHUNK_SIZE = 100 * 1024 * 1024
Expand Down Expand Up @@ -548,8 +556,15 @@ def auth_headers(self) -> dict[str, str]:
}


# This is only available for internal users to have long-lived access tokens
@dataclass
class FalFileRepositoryV3(FileRepository):
class InternalFalFileRepositoryV3(FileRepository):
"""
InternalFalFileRepositoryV3 is a file repository that uses the FAL CDN V3.
But generates and uses long-lived access tokens.
That way it can avoid the need to refresh the token for every upload.
"""

@retry(max_retries=3, base_delay=1, backoff_type="exponential", jitter=True)
def save(
self, file: FileData, object_lifecycle_preference: dict[str, str] | None
Expand Down

0 comments on commit add676b

Please sign in to comment.