|
|
|
@ -146,18 +146,21 @@ def upload(request): |
|
|
|
|
if not os.path.exists(file_path): |
|
|
|
|
os.makedirs(file_path) |
|
|
|
|
file_path = os.path.join(file_path, i.name) |
|
|
|
|
video = videoUpload.objects.filter(username=auth.get_user(request).username, video_title=i.name, |
|
|
|
|
video_size=i.size) |
|
|
|
|
video = videoUpload.objects.filter(video_title=i.name,video_size=i.size) |
|
|
|
|
if video.exists(): |
|
|
|
|
import shutil |
|
|
|
|
shutil.move(os.path.join(settings.MEDIA_ROOT,str(video.get().video_path).replace('/upload/','')), file_path) |
|
|
|
|
video.update(video_time=today, video_path=os.path.join('/upload/videos/',file_path.split(r"videos")[-1][1:].replace('\\','/'))) |
|
|
|
|
else: |
|
|
|
|
image = get_image('215x280', file_type) |
|
|
|
|
videoUpload.objects.create(username=auth.get_user(request).username, video_title=i.name, video_size=i.size, video_time=today, video_path=os.path.join('/upload/videos/',file_path.split(r"videos")[-1][1:].replace('\\','/')), video_image=image, video_desc=file_type) |
|
|
|
|
with open(file_path, 'wb') as f: |
|
|
|
|
for chunk in i.chunks(): |
|
|
|
|
f.write(chunk) |
|
|
|
|
try: |
|
|
|
|
videoUpload.objects.create(username=auth.get_user(request).username, video_title=i.name, video_size=i.size, video_time=today, video_path=os.path.join('/upload/videos/',file_path.split(r"videos")[-1][1:].replace('\\','/')), video_image=image, video_desc=file_type) |
|
|
|
|
with open(file_path, 'wb') as f: |
|
|
|
|
for chunk in i.chunks(): |
|
|
|
|
f.write(chunk) |
|
|
|
|
except Exception as e: |
|
|
|
|
print(e) |
|
|
|
|
|
|
|
|
|
if data: |
|
|
|
|
return HttpResponse(json.dumps(data)) |
|
|
|
|
elif ftype == 'editmd': |
|
|
|
|