Skip to content

Commit

Permalink
Update to allow for Cloudflare S3 download
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-data committed Jul 5, 2023
1 parent 33e5382 commit e483b8d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/dataplane/DataStorage/s3/s3_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
FilePath: /General/hello.xlxs
"""

def s3_download(S3Client, Bucket, S3FilePath, DownloadMethod="Object", LocalFilePath=""):
def s3_download(S3Client, Bucket, S3FilePath, DownloadMethod="Object", LocalFilePath="", ChecksumMode=''):

from datetime import datetime
from io import BytesIO
Expand All @@ -29,7 +29,10 @@ def s3_download(S3Client, Bucket, S3FilePath, DownloadMethod="Object", LocalFil
return {"result":"OK", "duration": str(duration), "FilePath": LocalFilePath}

# Download S3 file content to object
objectGet = S3Client.get_object(Bucket=Bucket, Key=S3FilePath, ChecksumMode='ENABLED')["Body"].read()
if ChecksumMode=="ENABLED":
objectGet = S3Client.get_object(Bucket=Bucket, Key=S3FilePath, ChecksumMode='ENABLED')["Body"].read()
else:
objectGet = S3Client.get_object(Bucket=Bucket, Key=S3FilePath)["Body"].read()

duration = datetime.now() - start
return {"result":"OK", "duration": str(duration), "content": objectGet}

0 comments on commit e483b8d

Please sign in to comment.