Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:12:08+00:00 2026-06-04T00:12:08+00:00

I’m building a django based database app that allows users to upload supporting documentation.

  • 0

I’m building a django based database app that allows users to upload supporting documentation. We’re expecting about 1 million pages of pdf by the end of the project. The repository will be broken down into 3,000 – 5,000 different folders (this is specified by the client). I have a single db table recording these documents. The table includes the name of the document and the folder the document is stored in.

I’m looking for the best way of serving these document back up to the client. I’ve got a basic search tool that lists documents in an html table. I want the table to include an html link to the uploaded document. I’m just not sure how to create this link. More specifically I’m not sure how to serve the files themselves. I want to use django rather than serving them directly through apache, as I want to use django’s permissions system.

Can I use the staticfiles app for this? I’m concerned that staticfiles looks like it wants to copy files from one place to another (which probably isn’t practical given the size of the repository). I’m also not sure how staticfiles will cope with the dynamic folder structure. We won’t know the folder structure untill the files are actually uploaded. Lastly the django docs say specifically that the static files app is not designed for user uploaded documents.

Perhaps I just need some sort of django view, but I can’t get the following to work –

def document(request, path, name):
    path = os.path.join(settings.DOCUMENT_ROOT, path, name)
    pdf = open(path, 'r')
    response = HttpResponse(pdf, mimetype='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=' + name
    return response

When adobe reader tries to open the attachment it tells me the file’s damaged (or not supported).
Any input would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:12:10+00:00Added an answer on June 4, 2026 at 12:12 am

    OK for the time being I’m just going with a simple django view –

    @login_required
    @permission_required('reporting.can_view_documents', raise_exception=True)
    def document(request, path, name):
        path = os.path.join(settings.DOCUMENT_ROOT, path, name)
        pdf = open(path, 'rb')
        response = HttpResponse(pdf.read(), mimetype='application/pdf')
        response['Content-Disposition'] = 'attachment; filename=' + name
        return response
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.