최지우

Bug Fix

......@@ -7,7 +7,6 @@ from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
from django.shortcuts import render
from django.contrib.auth.models import User
from api.videorecord import record
from api.models import Video, Device, RemoteHistory, Lock, Record, Door, AddDevice
from api.serializers import VideoSerializer, DeviceSerializer, RemoteHistorySerializer, RecordSerializer, LockSerializer, AddDeviceSerializer
......@@ -160,7 +159,7 @@ class Remote(APIView):
return Response(res, status = status.HTTP_200_OK)
# 원격 잠금 해제
def post(self, request, format = None) :
def put(self, request, format = None) :
try:
print(request.body)
data = json.loads(request.body)
......@@ -211,7 +210,8 @@ class VideoList(APIView) :
s3 = session.client('s3')
target = Video.objects.get(vid_name = request_id)
s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name))
s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '.mp4')
s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '_thumb.jpg')
target.delete()
return Response(status = status.HTTP_200_OK)
except FieldDoesNotExist as error :
......@@ -227,7 +227,7 @@ class VideoDownload(APIView) :
request_id = vid_name
if request_id == 'None' :
raise FieldDoesNotExist
download_url = S3_ACCESS_URL + str(request_id) # S3 다운로드 링크 변환
download_url = S3_ACCESS_URL + str(request_id) + '.mp4' # S3 다운로드 링크 변환
if not download_url :
raise ObjectDoesNotExist
res = {
......@@ -253,7 +253,7 @@ class CheckDate(APIView) :
session = boto3.session.Session(aws_access_key_id = S3_ACCESS_KEY_ID, aws_secret_access_key = S3_SECRET_ACCESS_KEY, region_name = AWS_REGION)
s3 = session.client('s3')
for delvid in quaryset :
s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(delvid.vid_name))
s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(delvid.vid_name) + '.mp4')
quaryset.delete()
return Response(status = status.HTTP_200_OK)
......
......@@ -83,14 +83,14 @@ def record() :
else:
ACCESS_KEY, SECRET_KEY = secret
s3 = boto3.client('s3', region_name = 'ap-northeast-2', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY)
s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name)
s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb')
s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '.mp4')
s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb.jpg')
uploadVideo = {}
uploadVideo['vid_name'] = vid_name
uploadVideo['created'] = now
uploadVideo['vid_time'] = vid_time
uploadVideo['thumb'] = S3_ACCESS_URL + vid_name + '_thumb'
uploadVideo['thumb'] = S3_ACCESS_URL + vid_name + '_thumb.jpg'
serializer = VideoSerializer(data = uploadVideo)
serializer.is_valid()
serializer.save()
......