mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
uploads: Add a method to copy attachment contents out.
This commit is contained in:
committed by
Tim Abbott
parent
885334a3ad
commit
e408f069fe
@@ -4,7 +4,7 @@ import secrets
|
||||
import urllib
|
||||
from datetime import datetime
|
||||
from mimetypes import guess_type
|
||||
from typing import IO, Any, Callable, Iterator, List, Optional, Tuple
|
||||
from typing import IO, Any, BinaryIO, Callable, Iterator, List, Optional, Tuple
|
||||
|
||||
import boto3
|
||||
import botocore
|
||||
@@ -231,6 +231,10 @@ class S3UploadBackend(ZulipUploadBackend):
|
||||
)
|
||||
return url
|
||||
|
||||
def save_attachment_contents(self, path_id: str, filehandle: BinaryIO) -> None:
|
||||
for chunk in self.uploads_bucket.Object(path_id).get()["Body"]:
|
||||
filehandle.write(chunk)
|
||||
|
||||
def delete_message_attachment(self, path_id: str) -> bool:
|
||||
return self.delete_file_from_s3(path_id, self.uploads_bucket)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user