Commit 5b58e6e9 authored by Ilya Simonov's avatar Ilya Simonov

fix send video to s3

parent de448400
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
import os
import requests
from django.conf import settings
from .models import Video, READY
from .s3_uploader import upload_file
......@@ -14,7 +17,10 @@ def send_video_to_s3():
for local_video in local_videos:
video_name = local_video.local_file.name.split('/')[-1]
key = asset_upload(local_video, video_name)
content = local_video.local_file.read()
file_path = settings.DOMAIN_NAME + settings.MEDIA_URL + key
response = requests.get(file_path)
content = response.content
local_video.s3_file = upload_file(content, key, 'video/mp4')
local_video.status = READY
......
......@@ -166,3 +166,5 @@ else:
AWS_REGION_NAME = env('AWS_REGION_NAME')
# CloudFront
AWS_S3_CUSTOM_DOMAIN = env('AWS_S3_CUSTOM_DOMAIN')
DOMAIN_NAME = env('DOMAIN_NAME', default='http://localhost:8000')
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