Commit c1b15440 authored by Ilya Simonov's avatar Ilya Simonov

fix create custom thumbnail

parent a5d38ab2
...@@ -36,16 +36,16 @@ def send_video_to_s3(): ...@@ -36,16 +36,16 @@ def send_video_to_s3():
local_video.s3_file = upload_file(content, key, 'video/mp4') local_video.s3_file = upload_file(content, key, 'video/mp4')
local_video.status = READY local_video.status = READY
if not local_video.thumbnail and local_video.local_file: # if not local_video.thumbnail and local_video.local_file:
log.info(f'Uploading thumbnail for video {local_video.id} to S3...') # log.info(f'Uploading thumbnail for video {local_video.id} to S3...')
thumbnail_name = generate_thumbnail(file_path, video_name) # thumbnail_name = generate_thumbnail(file_path, video_name)
key = f'videos/{thumbnail_name}' # key = f'videos/{thumbnail_name}'
thumbnail_path = settings.DOMAIN_NAME + settings.MEDIA_URL + thumbnail_name # thumbnail_path = settings.DOMAIN_NAME + settings.MEDIA_URL + thumbnail_name
response = requests.get(thumbnail_path) # response = requests.get(thumbnail_path)
content = response.content # content = response.content
content_type = 'image/jpeg' # content_type = 'image/jpeg'
local_video.thumbnail = upload_file(content, key, content_type) # local_video.thumbnail = upload_file(content, key, content_type)
log.info(f'Thumbnail for video {local_video.id} uploaded to S3...') # log.info(f'Thumbnail for video {local_video.id} uploaded to S3...')
local_video.save(update_fields=['s3_file', 'status', 'thumbnail']) local_video.save(update_fields=['s3_file', 'status', 'thumbnail'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment