mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-11 12:48:28 +03:00
s3 allow online preview instead of forced download
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import uuid, os
|
||||
import uuid, os, mimetypes
|
||||
from dataclasses import dataclass
|
||||
|
||||
import boto3
|
||||
@@ -21,6 +21,7 @@ class S3Config:
|
||||
private: bool = False
|
||||
key_path: str = "default" # 'default' uses full naming, 'random' uses generated uuid
|
||||
|
||||
|
||||
class S3Storage(Storage):
|
||||
|
||||
def __init__(self, config: S3Config):
|
||||
@@ -70,4 +71,5 @@ class S3Storage(Storage):
|
||||
extra_args = kwargs.get("extra_args", {})
|
||||
else:
|
||||
extra_args = kwargs.get("extra_args", {'ACL': 'public-read'})
|
||||
extra_args['ContentType'] = mimetypes.guess_type(key)[0]
|
||||
self.s3.upload_fileobj(file, Bucket=self.bucket, Key=self._get_path(key), ExtraArgs=extra_args)
|
||||
|
||||
Reference in New Issue
Block a user