Showing
1 changed file
with
8 additions
and
6 deletions
... | @@ -195,7 +195,7 @@ class ItemViewSet(viewsets.ViewSet): | ... | @@ -195,7 +195,7 @@ class ItemViewSet(viewsets.ViewSet): |
195 | s3_bucket = AWS_STORAGE_BUCKET_NAME | 195 | s3_bucket = AWS_STORAGE_BUCKET_NAME |
196 | 196 | ||
197 | item = Item.objects.filter(item_id=pk) | 197 | item = Item.objects.filter(item_id=pk) |
198 | - object_name = item.get().name | 198 | + object_name = str(item.get().item_id) |
199 | data = serializers.serialize("json", item) | 199 | data = serializers.serialize("json", item) |
200 | json_data = json.loads(data) | 200 | json_data = json.loads(data) |
201 | 201 | ||
... | @@ -299,7 +299,8 @@ class ItemViewSet(viewsets.ViewSet): | ... | @@ -299,7 +299,8 @@ class ItemViewSet(viewsets.ViewSet): |
299 | return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT) | 299 | return Response({'message': 'item is not existed.'}, status=status.HTTP_204_NO_CONTENT) |
300 | if child.is_folder == True: | 300 | if child.is_folder == True: |
301 | return Response({'message': 'item is folder'}, status=status.HTTP_204_NO_CONTENT) | 301 | return Response({'message': 'item is folder'}, status=status.HTTP_204_NO_CONTENT) |
302 | - copiedName = child.name + "_복사본_" + str(datetime.now().strftime('%Y-%m-%d %H:%M')) | 302 | + name = child.name.split(".") |
303 | + copiedName = name[0]+ "_복사본_" + str(datetime.now().strftime('%Y-%m-%d %H:%M'))+"." + name[-1] | ||
303 | copiedItem = Item(is_folder=False, name=copiedName, path=child.path, parent=parent_id, | 304 | copiedItem = Item(is_folder=False, name=copiedName, path=child.path, parent=parent_id, |
304 | user_id=child.user_id, size=child.size, status=child.status) | 305 | user_id=child.user_id, size=child.size, status=child.status) |
305 | copiedItem.save() | 306 | copiedItem.save() |
... | @@ -403,11 +404,13 @@ class ItemViewSet(viewsets.ViewSet): | ... | @@ -403,11 +404,13 @@ class ItemViewSet(viewsets.ViewSet): |
403 | upload_item = Item(name=file_name, size=file_size, user_id=1, file_type=file_type, parent=file_parent) | 404 | upload_item = Item(name=file_name, size=file_size, user_id=1, file_type=file_type, parent=file_parent) |
404 | upload_item.save() | 405 | upload_item.save() |
405 | 406 | ||
407 | + file_id = str(upload_item.item_id) | ||
408 | + | ||
406 | date_long = datetime.utcnow().strftime('%Y%m%dT000000Z') | 409 | date_long = datetime.utcnow().strftime('%Y%m%dT000000Z') |
407 | 410 | ||
408 | presigned_post = s3.generate_presigned_post( | 411 | presigned_post = s3.generate_presigned_post( |
409 | s3_bucket, | 412 | s3_bucket, |
410 | - file_name, | 413 | + file_id, |
411 | { | 414 | { |
412 | "acl": "private", | 415 | "acl": "private", |
413 | "Content-Type": file_type, | 416 | "Content-Type": file_type, |
... | @@ -434,7 +437,7 @@ class ItemViewSet(viewsets.ViewSet): | ... | @@ -434,7 +437,7 @@ class ItemViewSet(viewsets.ViewSet): |
434 | 437 | ||
435 | data = { | 438 | data = { |
436 | "signed_url": presigned_post, | 439 | "signed_url": presigned_post, |
437 | - 'url': '%s/%s' % (presigned_post["url"], file_name), | 440 | + 'url': '%s/%s' % (presigned_post["url"], file_id), |
438 | 'item': res | 441 | 'item': res |
439 | } | 442 | } |
440 | 443 | ||
... | @@ -476,7 +479,6 @@ class SharedItemViewSet(viewsets.ModelViewSet): | ... | @@ -476,7 +479,6 @@ class SharedItemViewSet(viewsets.ModelViewSet): |
476 | return Response({'message': 'This file is already shared'}, status=status.HTTP_200_OK) | 479 | return Response({'message': 'This file is already shared'}, status=status.HTTP_200_OK) |
477 | sharedfile = SharedItem(item_id=pk, password=password, expires=expires) | 480 | sharedfile = SharedItem(item_id=pk, password=password, expires=expires) |
478 | sharedfile.save() | 481 | sharedfile.save() |
479 | - sharedfile = SharedItem.objects.get(item_id=pk) | ||
480 | 482 | ||
481 | # sf = serializers.serialize("json", sharedfile) | 483 | # sf = serializers.serialize("json", sharedfile) |
482 | item = Item.objects.filter(item_id=pk) | 484 | item = Item.objects.filter(item_id=pk) |
... | @@ -486,7 +488,7 @@ class SharedItemViewSet(viewsets.ModelViewSet): | ... | @@ -486,7 +488,7 @@ class SharedItemViewSet(viewsets.ModelViewSet): |
486 | print(json_data) | 488 | print(json_data) |
487 | res = json_data[0]['fields'] | 489 | res = json_data[0]['fields'] |
488 | res['id'] = json_data[0]['pk'] | 490 | res['id'] = json_data[0]['pk'] |
489 | - return Response({"shared": sharedfile.created_time, 'data': res}, status=status.HTTP_200_OK) | 491 | + return Response({"shared": sharedfile.pk, 'data': res}, status=status.HTTP_200_OK) |
490 | 492 | ||
491 | 493 | ||
492 | item = ItemViewSet.as_view({ | 494 | item = ItemViewSet.as_view({ | ... | ... |
-
Please register or login to post a comment