Commit 0bc66e80 authored by Ilya Simonov's avatar Ilya Simonov

fix utils asset_upload

parent 173868ae
# Generated by Django 4.1.7 on 2023-03-06 16:52
import apps.core.utils
import cp_video.utils
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
......@@ -78,7 +78,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='video',
name='thumbnail',
field=models.ImageField(blank=True, max_length=500, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(bucket_name='clutchpoints-videos'), upload_to=apps.core.utils.asset_upload, verbose_name='thumbnail'),
field=models.ImageField(blank=True, max_length=500, null=True, storage=storages.backends.s3boto3.S3Boto3Storage(bucket_name='clutchpoints-videos'), upload_to=cp_video.utils.asset_upload, verbose_name='thumbnail'),
),
migrations.AlterField(
model_name='video',
......
# Generated by Django 4.1.7 on 2023-03-21 11:17
import apps.core.utils
import cp_video.utils
from django.db import migrations, models
......@@ -19,6 +19,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='video',
name='local_file',
field=models.FileField(blank=True, null=True, upload_to=apps.core.utils.asset_upload, verbose_name='local file'),
field=models.FileField(blank=True, null=True, upload_to=cp_video.utils.asset_upload, verbose_name='local file'),
),
]
......@@ -8,7 +8,7 @@ from pytils.translit import slugify
from storages.backends.s3boto3 import S3Boto3Storage
from .utils import asset_upload
from cp_video.utils import asset_upload
READY = 'ready'
......
......@@ -5,20 +5,20 @@ from django.conf import settings
from .models import Video, READY, FAIL
from .s3_uploader import upload_file
from .utils import asset_upload, add_video_to_playlist
from .utils import add_video_to_playlist
from cp_video.celery import app
from cp_video.utils import asset_upload
log = logging.getLogger('send_video_to_s3')
@app.task(soft_time_limit=600)
def send_video_to_s3(video_id=None):
log.info(f'Uploading video id {video_id} to S3...')
local_video = Video.objects.get(id=video_id)
try:
log.info(f'Uploading video id {local_video.id} to S3...')
video_name = local_video.local_file.name.split('/')[-1]
key = asset_upload(local_video, video_name)
file_path = settings.DOMAIN_NAME + settings.MEDIA_URL + key
......
def asset_upload(instance, filename):
return f'videos/{filename}'
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