add view for file thumbnail in admin
This commit is contained in:
parent
0cb925bdad
commit
a95f741f68
2 changed files with 12 additions and 3 deletions
|
@ -40,3 +40,11 @@ def file_download(request, id, token):
|
||||||
def hotlink_file_download(request, id):
|
def hotlink_file_download(request, id):
|
||||||
file = get_object_or_404(SharedFile, short_id=id, hotlink=True, published=True)
|
file = get_object_or_404(SharedFile, short_id=id, hotlink=True, published=True)
|
||||||
return FileResponse(file)
|
return FileResponse(file)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def uploaded_file(request, filename):
|
||||||
|
file = get_object_or_404(SharedFile, file=request.get_full_path()[1:]) # strip preceding slash
|
||||||
|
response = FileResponse(file)
|
||||||
|
del response['Content-Disposition']
|
||||||
|
return response
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from project.files import views
|
from project.files.views import uploaded_file
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', include(admin.site.urls)),
|
url(r'^admin/', include(admin.site.urls)),
|
||||||
url(r'^admin_resumable/', include('admin_resumable.urls')),
|
url(r'^admin_resumable/', include('admin_resumable.urls')),
|
||||||
url(r'^files/', include('project.files.urls', namespace="files"))
|
url(r'^files/', include('project.files.urls', namespace="files")),
|
||||||
url(r'', include("project.pages.urls", namespace="pages")),
|
url(r'^uploads/(?P<filename>.*)', uploaded_file, name="upload"),
|
||||||
|
url(r'', include("project.pages.urls", namespace="pages"))
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue