mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-22 00:03:28 +01:00
S3 support - draft
This commit is contained in:
parent
7237040777
commit
28f16cbd83
@ -32,3 +32,16 @@ CELERY_RESULT_BACKEND = BROKER_URL
|
|||||||
MP4HLS_COMMAND = "/home/mediacms.io/bento4/bin/mp4hls"
|
MP4HLS_COMMAND = "/home/mediacms.io/bento4/bin/mp4hls"
|
||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
|
USE_S3_FOR_MEDIA_STORAGE = True
|
||||||
|
AWS_ACCESS_KEY = 'x'
|
||||||
|
AWS_SECRET_KEY = 'Y'
|
||||||
|
S3_BUCKET_NAME = 'Z'
|
||||||
|
|
||||||
|
|
||||||
|
# S3 work plan
|
||||||
|
# 1. Enter settings that you're using S3 OK
|
||||||
|
# 2. Enter a migration remote_urls on Media/Encode OK
|
||||||
|
# 3. add task that puts content to S3, removes local file, sets remote_urls
|
||||||
|
# 4. API response for orig/encod/hls from S3 --> plays??
|
||||||
|
# 5. script to migrate existing to S3
|
||||||
|
23
files/migrations/0003_remote_urls.py
Normal file
23
files/migrations/0003_remote_urls.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.8 on 2021-07-26 16:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('files', '0002_auto_20201201_0712'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='encoding',
|
||||||
|
name='remote_urls',
|
||||||
|
field=models.JSONField(default=dict, help_text='This will keep any url'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='media',
|
||||||
|
name='remote_urls',
|
||||||
|
field=models.JSONField(default=dict, help_text='This will keep any url'),
|
||||||
|
),
|
||||||
|
]
|
@ -284,6 +284,8 @@ class Media(models.Model):
|
|||||||
video_height = models.IntegerField(default=1)
|
video_height = models.IntegerField(default=1)
|
||||||
|
|
||||||
views = models.IntegerField(db_index=True, default=1)
|
views = models.IntegerField(db_index=True, default=1)
|
||||||
|
# this will keep any cloud url info, as original_file, probably hls files, encoding files etc
|
||||||
|
remote_urls = models.JSONField(default=dict, help_text='This will keep any url')
|
||||||
|
|
||||||
# keep track if media file has changed, on saves
|
# keep track if media file has changed, on saves
|
||||||
__original_media_file = None
|
__original_media_file = None
|
||||||
@ -691,7 +693,11 @@ class Media(models.Model):
|
|||||||
|
|
||||||
ep = {}
|
ep = {}
|
||||||
ep["title"] = encoding.profile.name
|
ep["title"] = encoding.profile.name
|
||||||
ep["url"] = encoding.media_encoding_url
|
if encoding.remote_urls and encoding.remote_urls.get('media_encoding_url'):
|
||||||
|
url = encoding.remote_urls.get('media_encoding_url')
|
||||||
|
else:
|
||||||
|
url = encoding.media_encoding_url
|
||||||
|
ep["url"] = url
|
||||||
ep["progress"] = encoding.progress
|
ep["progress"] = encoding.progress
|
||||||
ep["size"] = encoding.size
|
ep["size"] = encoding.size
|
||||||
ep["encoding_id"] = encoding.id
|
ep["encoding_id"] = encoding.id
|
||||||
@ -731,11 +737,15 @@ class Media(models.Model):
|
|||||||
def original_media_url(self):
|
def original_media_url(self):
|
||||||
"""Property used on serializers"""
|
"""Property used on serializers"""
|
||||||
|
|
||||||
if settings.SHOW_ORIGINAL_MEDIA:
|
if not settings.SHOW_ORIGINAL_MEDIA:
|
||||||
return helpers.url_from_path(self.media_file.path)
|
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if self.remote_urls and self.remote_urls.get('original_media_url'):
|
||||||
|
url = self.remote_urls.get('original_media_url')
|
||||||
|
else:
|
||||||
|
url = helpers.url_from_path(self.media_file.path)
|
||||||
|
return url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def thumbnail_url(self):
|
def thumbnail_url(self):
|
||||||
"""Property used on serializers
|
"""Property used on serializers
|
||||||
@ -1077,6 +1087,9 @@ class Encoding(models.Model):
|
|||||||
|
|
||||||
worker = models.CharField(max_length=100, blank=True)
|
worker = models.CharField(max_length=100, blank=True)
|
||||||
|
|
||||||
|
# this will keep any cloud url info, as original_file, probably hls files, encoding files etc
|
||||||
|
remote_urls = models.JSONField(default=dict, help_text='This will keep any url')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_encoding_url(self):
|
def media_encoding_url(self):
|
||||||
if self.media_file:
|
if self.media_file:
|
||||||
|
@ -31,3 +31,5 @@ django-ckeditor
|
|||||||
django-debug-toolbar
|
django-debug-toolbar
|
||||||
|
|
||||||
django-login-required-middleware==0.6.1
|
django-login-required-middleware==0.6.1
|
||||||
|
|
||||||
|
boto3==1.17.111
|
||||||
|
Loading…
Reference in New Issue
Block a user