From 54317628e09e93dbb76fe1b6551242b7b61087a1 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Tue, 29 Oct 2024 06:38:32 -0400 Subject: [PATCH] download button for content! modified: make_post_sell/views/content.py --- make_post_sell/views/content.py | 53 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/make_post_sell/views/content.py b/make_post_sell/views/content.py index 495dd19..3ea6b22 100644 --- a/make_post_sell/views/content.py +++ b/make_post_sell/views/content.py @@ -30,41 +30,36 @@ def content(request): bucket_name = request.app["bucket.secure_uploads"] - if ( - request.user - and request.user.authenticated - and request.user.can_download_product(product) - ): - # Params: Bucket, IfMatch, IfModifiedSince, IfNoneMatch, IfUnmodifiedSince, - # Key, Range, ResponseCacheControl, ResponseContentDisposition, ResponseProductEncoding, - # ResponseContentLanguage, ResponseContentType, ResponseExpires, VersionId, - # SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, RequestPayer, PartNumber + # Params: Bucket, IfMatch, IfModifiedSince, IfNoneMatch, IfUnmodifiedSince, + # Key, Range, ResponseCacheControl, ResponseContentDisposition, ResponseProductEncoding, + # ResponseContentLanguage, ResponseContentType, ResponseExpires, VersionId, + # SSECustomerAlgorithm, SSECustomerKey, SSECustomerKeyMD5, RequestPayer, PartNumber - params = { - "Bucket": bucket_name, - "Key": product.s3_key, - } + params = { + "Bucket": bucket_name, + "Key": product.s3_key, + } - # The content disposition string determines whether this is: - # * an inline image (thumbnails) - # * an attachment (file download) - content_disposition = product.get_content_disposition("content") + # The content disposition string determines whether this is: + # * an inline image (thumbnails) + # * an attachment (file download) + content_disposition = product.get_content_disposition("content") - # The content type string determines whether this is a pdf, zip, etc. - content_type = product.get_content_type("content") + # The content type string determines whether this is a pdf, zip, etc. + content_type = product.get_content_type("content") - if content_disposition: - params["ResponseContentDisposition"] = content_disposition + if content_disposition: + params["ResponseContentDisposition"] = content_disposition - if content_type: - params["ResponseContentType"] = content_type + if content_type: + params["ResponseContentType"] = content_type - signed_get_object_url = request.secure_uploads_client.generate_presigned_url( - ClientMethod="get_object", - Params=params, - # 15 minutes. - ExpiresIn=900, - ) + signed_get_object_url = request.secure_uploads_client.generate_presigned_url( + ClientMethod="get_object", + Params=params, + # 15 minutes. + ExpiresIn=900, + ) product_size = "" if product.has_product_file: