download button for content!
modified: make_post_sell/views/content.py
This commit is contained in:
parent
8f5c341539
commit
54317628e0
1 changed files with 24 additions and 29 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue