mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-17 15:32:36 +00:00
create metadata before uploading file
This commit is contained in:
parent
06a76f3ff6
commit
279736cfc4
1 changed files with 12 additions and 12 deletions
|
|
@ -129,20 +129,10 @@ class S3FilesImpl(Files):
|
|||
|
||||
filename = getattr(file, "filename", None) or "uploaded_file"
|
||||
|
||||
try:
|
||||
content = await file.read()
|
||||
file_size = len(content)
|
||||
self.client.put_object(
|
||||
Bucket=self._config.bucket_name,
|
||||
Key=file_id,
|
||||
Body=content,
|
||||
# TODO: enable server-side encryption
|
||||
)
|
||||
except ClientError as e:
|
||||
raise RuntimeError(f"Failed to upload file to S3: {e}") from e
|
||||
|
||||
created_at = int(time.time())
|
||||
expires_at = created_at + self._SILLY_EXPIRATION_OFFSET
|
||||
content = await file.read()
|
||||
file_size = len(content)
|
||||
|
||||
await self.sql_store.insert(
|
||||
"openai_files",
|
||||
|
|
@ -156,6 +146,16 @@ class S3FilesImpl(Files):
|
|||
},
|
||||
)
|
||||
|
||||
try:
|
||||
self.client.put_object(
|
||||
Bucket=self._config.bucket_name,
|
||||
Key=file_id,
|
||||
Body=content,
|
||||
# TODO: enable server-side encryption
|
||||
)
|
||||
except ClientError as e:
|
||||
raise RuntimeError(f"Failed to upload file to S3: {e}") from e
|
||||
|
||||
return OpenAIFileObject(
|
||||
id=file_id,
|
||||
filename=filename,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue