Skip to content

Commit

Permalink
change s3 bucket from githubclone to codepo due to s3 mess...
Browse files Browse the repository at this point in the history
  • Loading branch information
boyuan12 authored Sep 25, 2024
1 parent 6c2d05a commit d08e379
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions repo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def random_str(n):
def upload_s3(request, data=None, filename=False):
name = random_str(10)
if data == None:
s3.Bucket('githubclone').put_object(Key=f"{name}{pathlib.Path(request.FILES['file'].name).suffix}", Body=request.FILES["file"], ACL="public-read")
s3.Bucket('codepo').put_object(Key=f"{name}{pathlib.Path(request.FILES['file'].name).suffix}", Body=request.FILES["file"], ACL="public-read")
return f"{name}{pathlib.Path(request.FILES['file'].name).suffix}"
else:
s3.Bucket('githubclone').put_object(Key=f"{name}{pathlib.Path(filename).suffix}", Body=data, ACL="public-read")
s3.Bucket('codepo').put_object(Key=f"{name}{pathlib.Path(filename).suffix}", Body=data, ACL="public-read")
return f"{name}{pathlib.Path(filename).suffix}"


def get_s3(name):
obj = s3.Object("githubclone", f"{name}")
obj = s3.Object("codepo", f"{name}")
body = obj.get()['Body'].read()
return body

Expand Down

0 comments on commit d08e379

Please sign in to comment.