fix: changed migration and added public s3

This commit is contained in:
NarayanBavisetti 2023-10-27 12:50:12 +05:30
parent 2628890068
commit 4ce3fa356a
3 changed files with 5 additions and 6 deletions

View File

@ -106,14 +106,14 @@ def upload_to_s3(zip_file, workspace_id, token_id, slug):
)
s3.upload_fileobj(
zip_file,
settings.AWS_S3_BUCKET_NAME,
settings.AWS_PUBLIC_STORAGE_BUCKET_NAME,
file_name,
ExtraArgs={"ACL": "public-read", "ContentType": "application/zip"},
)
presigned_url = s3.generate_presigned_url(
"get_object",
Params={"Bucket": settings.AWS_S3_BUCKET_NAME, "Key": file_name},
Params={"Bucket": settings.AWS_PUBLIC_STORAGE_BUCKET_NAME, "Key": file_name},
ExpiresIn=expires_in,
)

View File

@ -44,6 +44,6 @@ def delete_old_s3_link():
if settings.DOCKERIZED and settings.USE_MINIO:
s3.delete_object(Bucket=settings.AWS_STORAGE_BUCKET_NAME, Key=file_name)
else:
s3.delete_object(Bucket=settings.AWS_S3_BUCKET_NAME, Key=file_name)
s3.delete_object(Bucket=settings.AWS_PUBLIC_STORAGE_BUCKET_NAME, Key=file_name)
ExporterHistory.objects.filter(id=exporter_id).update(url=None)

View File

@ -1,7 +1,6 @@
# Generated by Django 4.2.3 on 2023-09-21 14:16
import boto3
import botocore
from django.db import migrations
from django.conf import settings
@ -31,9 +30,9 @@ def move_s3_objects(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
("db", "0047_auto_20230921_0758"),
("db", "0045_issueactivity_epoch_workspacemember_issue_props_and_more"),
]
operations = [
migrations.RunPython(move_s3_objects),
]
]