Commit d4d437ab authored by Ilya Simonov's avatar Ilya Simonov

fix upload file

parent 76248acd
No preview for this file type
import requests
import os
import logging
from django.conf import settings
......@@ -27,9 +27,6 @@ def send_video_to_s3(video_id=None):
file_path = settings.DOMAIN_NAME + settings.MEDIA_URL + key
log.info(f'File path: {file_path}')
# response = requests.get(file_path)
# log.info(f'response status code {response.status_code}')
# content = response.content
content = download_file(file_path)
log.info('get content successfully!')
......@@ -50,6 +47,7 @@ def send_video_to_s3(video_id=None):
log.info(f'Video id {local_video.id} uploaded to S3...')
add_video_to_playlist(local_video)
os.remove(content)
except Exception as e:
log.error(e)
......
......@@ -20,10 +20,6 @@ def download_file(url):
r.raise_for_status()
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
log.info('chunk')
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
#if chunk:
f.write(chunk)
return local_filename
......@@ -32,7 +28,7 @@ def download_file(url):
def generate_thumbnail(video_path, video_name):
clip = VideoFileClip(video_path)
thumbnail_name = video_name.split('.')[0]
thumbnail_name = f'{settings.MEDIA_ROOT}{thumbnail_name}.jpg'
thumbnail_name = f'{settings.DOMAIN_NAME}{settings.MEDIA_ROOT}{thumbnail_name}.jpg'
clip.save_frame(thumbnail_name, t=1.00)
thumbnail_name = thumbnail_name.split('/')[-1]
......
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