mirror of
https://github.com/MarcZierle/photo-log-backend.git
synced 2024-12-29 10:57:58 +00:00
fix s3 uploads arguments
This commit is contained in:
parent
68df020da0
commit
9a39f3776d
@ -66,7 +66,7 @@ def download_s3_file(folder_path, s3_file_path, bucket):
|
||||
|
||||
|
||||
@shared_task
|
||||
def upload_s3_file(file_path, s3_file_path, bucket):
|
||||
def upload_s3_file(file_path, s3_file_path, bucket, content_type='application/octet-stream'):
|
||||
"""
|
||||
Uploads a file to a S3 object storages.
|
||||
:param file_path Path on local disk where the is saved.
|
||||
@ -82,7 +82,15 @@ def upload_s3_file(file_path, s3_file_path, bucket):
|
||||
)
|
||||
client = s3_resource.meta.client
|
||||
|
||||
client.upload_file(file_path, bucket, s3_file_path)
|
||||
client.upload_file(
|
||||
file_path,
|
||||
bucket,
|
||||
s3_file_path,
|
||||
ExtraArgs={
|
||||
'ContentDisposition': 'inline',
|
||||
'ContentType': content_type,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@shared_task
|
||||
@ -216,7 +224,8 @@ def max_resize_image_chain(full_file_name, max_width, work_folder_name=uuid4()):
|
||||
upload_s3_file.si(
|
||||
local_file,
|
||||
full_file_name,
|
||||
bucket
|
||||
bucket,
|
||||
content_type='image/png'
|
||||
),
|
||||
delete_folder.si(
|
||||
folder
|
||||
@ -250,12 +259,19 @@ def crop_image_bbox_chain(photo_pk, full_file_name, bbox, rotate_angle, cropped_
|
||||
upload_s3_file.si(
|
||||
local_file,
|
||||
s3_upload_name,
|
||||
bucket
|
||||
bucket,
|
||||
content_type='image/png'
|
||||
),
|
||||
update_model_field.si(# photo_log.Photo(pk=photo_pk).cropped_image = s3_upload_name
|
||||
'photo_log', 'Photo', photo_pk,
|
||||
'cropped_image', s3_upload_name
|
||||
),
|
||||
notify_client.si(
|
||||
description='update_photo',
|
||||
content={
|
||||
'id': photo_pk
|
||||
}
|
||||
),
|
||||
delete_folder.si(
|
||||
folder
|
||||
),
|
||||
@ -286,7 +302,8 @@ def crop_image_auto_chain(photo_pk, full_file_name, cropped_img_name=None, work_
|
||||
upload_s3_file.si(
|
||||
local_file,
|
||||
s3_upload_name,
|
||||
bucket
|
||||
bucket,
|
||||
content_type='image/png'
|
||||
),
|
||||
update_model_field.si(# photo_log.Photo(pk=photo_pk).cropped_image = s3_upload_name
|
||||
'photo_log', 'Photo', photo_pk,
|
||||
@ -390,7 +407,8 @@ def generate_photo_log_chain(photo_log_id, work_folder_name=uuid4()):
|
||||
upload_s3_file.si(
|
||||
pdf_file,
|
||||
pdf_s3_path,
|
||||
bucket
|
||||
bucket,
|
||||
content_type='application/pdf'
|
||||
),
|
||||
update_model_field.si(
|
||||
'photo_log', 'PhotoLog', photo_log.id,
|
||||
|
Loading…
Reference in New Issue
Block a user