-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup basic s3 integration for songs + extracted some keys to .env
- Loading branch information
Showing
7 changed files
with
67 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
server/music/migrations/0003_remove_track_url_track_s3_key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.1.4 on 2025-01-26 12:32 | ||
|
||
import django.utils.timezone | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('music', '0002_alter_track_channels_alter_track_featuring_artists'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='track', | ||
name='url', | ||
), | ||
migrations.AddField( | ||
model_name='track', | ||
name='s3_key', | ||
field=models.CharField(default=django.utils.timezone.now, max_length=200), | ||
preserve_default=False, | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
server/music/migrations/0004_alter_track_featuring_artists.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1.4 on 2025-02-01 13:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('music', '0003_remove_track_url_track_s3_key'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='track', | ||
name='featuring_artists', | ||
field=models.CharField(blank=True, max_length=500, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
from rest_framework import serializers | ||
from .models import Track | ||
import os | ||
|
||
class TrackSerializer(serializers.ModelSerializer): | ||
s3_url = serializers.SerializerMethodField('get_s3_url') | ||
|
||
def get_s3_url(self, track): | ||
AWS_BUCKET_NAME = os.getenv('AWS_BUCKET_NAME') | ||
AWS_BUCKET_REGION = os.getenv('AWS_BUCKET_REGION') | ||
return f"http://{AWS_BUCKET_NAME}.s3.{AWS_BUCKET_REGION}.amazonaws.com/audio/{track.s3_key}" | ||
|
||
class Meta: | ||
model = Track | ||
fields = '__all__' | ||
fields = ['title', 'artist', 'featuring_artists', 's3_url'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters