feat(files, s3, expiration): add expires_after support to S3 files provider

this also updates the localfs provider to reject the optional expires_after.

[API CHANGE] Add optional expires_after to POST /v1/files.
This commit is contained in:
Matthew Farrellee 2025-08-29 09:09:09 -04:00
parent ed418653ec
commit 76a59e4a55
9 changed files with 371 additions and 81 deletions

View file

@ -86,11 +86,16 @@ class LocalfsFilesImpl(Files):
self,
file: Annotated[UploadFile, File()],
purpose: Annotated[OpenAIFilePurpose, Form()],
expires_after_anchor: Annotated[str | None, Form(alias="expires_after[anchor]")] = None,
expires_after_seconds: Annotated[int | None, Form(alias="expires_after[seconds]")] = None,
) -> OpenAIFileObject:
"""Upload a file that can be used across various endpoints."""
if not self.sql_store:
raise RuntimeError("Files provider not initialized")
if expires_after_anchor is not None or expires_after_seconds is not None:
raise NotImplementedError("File expiration is not supported by this provider")
file_id = self._generate_file_id()
file_path = self._get_file_path(file_id)