Showing
2 changed files
with
5 additions
and
23 deletions
... | @@ -210,7 +210,7 @@ class VideoList(APIView) : | ... | @@ -210,7 +210,7 @@ class VideoList(APIView) : |
210 | s3 = session.client('s3') | 210 | s3 = session.client('s3') |
211 | 211 | ||
212 | target = Video.objects.get(vid_name = request_id) | 212 | target = Video.objects.get(vid_name = request_id) |
213 | - s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '.mp4') | 213 | + s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '.h264') |
214 | s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '_thumb.jpg') | 214 | s3.delete_object(Bucket = S3_STORAGE_BUCKET_NAME, Key = str(target.vid_name) + '_thumb.jpg') |
215 | target.delete() | 215 | target.delete() |
216 | return Response(status = status.HTTP_200_OK) | 216 | return Response(status = status.HTTP_200_OK) |
... | @@ -227,7 +227,7 @@ class VideoDownload(APIView) : | ... | @@ -227,7 +227,7 @@ class VideoDownload(APIView) : |
227 | request_id = vid_name | 227 | request_id = vid_name |
228 | if request_id == 'None' : | 228 | if request_id == 'None' : |
229 | raise FieldDoesNotExist | 229 | raise FieldDoesNotExist |
230 | - download_url = S3_ACCESS_URL + str(request_id) + '.mp4' # S3 다운로드 링크 변환 | 230 | + download_url = S3_ACCESS_URL + str(request_id) + '.h264' # S3 다운로드 링크 변환 |
231 | if not download_url : | 231 | if not download_url : |
232 | raise ObjectDoesNotExist | 232 | raise ObjectDoesNotExist |
233 | res = { | 233 | res = { | ... | ... |
... | @@ -21,17 +21,6 @@ from picamera import PiCamera | ... | @@ -21,17 +21,6 @@ from picamera import PiCamera |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | -def get_secret(): | ||
25 | - file_path = "/home/pi/Desktop/smartdoorlock-backend/.aws_key.json" | ||
26 | - if os.path.exists(file_path): | ||
27 | - with open(file_path) as fp: | ||
28 | - secret_file = json.load(fp)['aws'] | ||
29 | - access_key_id = secret_file.get('access_key_id', None) | ||
30 | - secret_access_key = secret_file.get('secret_access_key', None) | ||
31 | - return (access_key_id, secret_access_key) | ||
32 | - else: | ||
33 | - return False | ||
34 | - | ||
35 | def record() : | 24 | def record() : |
36 | path = '/home/pi/recorded' # save path | 25 | path = '/home/pi/recorded' # save path |
37 | 26 | ||
... | @@ -60,7 +49,7 @@ def record() : | ... | @@ -60,7 +49,7 @@ def record() : |
60 | start_time = time.time() | 49 | start_time = time.time() |
61 | 50 | ||
62 | vid_name = now.strftime('%Y%m%d-%H%M%S') | 51 | vid_name = now.strftime('%Y%m%d-%H%M%S') |
63 | - vid_path = path + '/' + vid_name + '.mp4' | 52 | + vid_path = path + '/' + vid_name + '.h264' |
64 | thumbnail_path = path + '/' + vid_name + '.jpg' | 53 | thumbnail_path = path + '/' + vid_name + '.jpg' |
65 | 54 | ||
66 | camera.start_recording(output=vid_path) | 55 | camera.start_recording(output=vid_path) |
... | @@ -75,15 +64,8 @@ def record() : | ... | @@ -75,15 +64,8 @@ def record() : |
75 | vid_time = time.strftime("%M:%S", time.gmtime(time.time()-start_time)) | 64 | vid_time = time.strftime("%M:%S", time.gmtime(time.time()-start_time)) |
76 | 65 | ||
77 | # s3 upload | 66 | # s3 upload |
78 | - secret = get_secret() | 67 | + s3 = boto3.client('s3', region_name = 'ap-northeast-2', aws_access_key_id=S3_ACCESS_KEY_ID, aws_secret_access_key=S3_SECRET_ACCESS_KEY) |
79 | - if not secret: | 68 | + s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '.h264') |
80 | - print(vid_path, "upload failed") | ||
81 | - print("please make credential file") | ||
82 | - exit(0) | ||
83 | - else: | ||
84 | - ACCESS_KEY, SECRET_KEY = secret | ||
85 | - s3 = boto3.client('s3', region_name = 'ap-northeast-2', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY) | ||
86 | - s3.upload_file(Filename = vid_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '.mp4') | ||
87 | s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb.jpg') | 69 | s3.upload_file(Filename = thumbnail_path, Bucket = S3_STORAGE_BUCKET_NAME, Key = vid_name + '_thumb.jpg') |
88 | 70 | ||
89 | uploadVideo = {} | 71 | uploadVideo = {} | ... | ... |
-
Please register or login to post a comment