Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes for Docker and image downloading #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get update && apt-get install -y \

COPY requirements.txt /app/
RUN pip install --upgrade pip \
&& pip install --no-cache-dir llvmlite==0.31.0 \
&& pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir gunicorn psycopg2-binary

Expand Down
18 changes: 10 additions & 8 deletions annotator/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import logging
import subprocess
import re
import os
import mimetypes
#import cv2
#import numpy as np
from django.shortcuts import render
Expand All @@ -12,7 +14,8 @@
from django.views.decorators.cache import never_cache
from django.db import IntegrityError
from django.db.models import Max
from django.http import JsonResponse
from django.http import JsonResponse, StreamingHttpResponse
from wsgiref.util import FileWrapper
from celery.result import AsyncResult
from celery import chain
from celery import states as task_states
Expand Down Expand Up @@ -709,13 +712,12 @@ class ExportVideo(View):
def get(self, request, vid):
video = Video.objects.get(id=vid)
if video.zipfile and os.path.exists(video.zipfile.path):
with open(video.zipfile.path, 'rb') as f:
response = HttpResponse(
f, content_type='application/x-zip-compressed')
response['Content-Disposition'] = (
'attachment; '
'filename={}.zip'
).format(video.name)
chunk_size = 8192
filename = os.path.basename(video.zipfile.path)
response = StreamingHttpResponse(FileWrapper(open(video.zipfile.path, 'rb'), chunk_size),
content_type=mimetypes.guess_type(video.zipfile.path)[0])
response['Content-Length'] = os.path.getsize(video.zipfile.path)
response['Content-Disposition'] = "attachment; filename=%s" % filename
else:
response = HttpResponseNotFound('File does not exist')
return response
Expand Down