🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27839

[pylons] Zwracanie pliku z bazy danych

#27839
From: Parasit Hendersson
Date: Wed, 08 Dec 2010 13:41
21 lines
1643 bytes
Witam
Mam w bazie danych przechowywane różne dokumenty, konkretnie jest to pole
LBLOB w MySQLu.
W pylonsach robię wyszukiwanie, katalogowanie itp. oraz umożliwiam pobranie
pliku.
Problem polega na tym, że po kliknięciu w link przeglądarka od razu otwiera
plik a chciałbym żeby pojawiła się kontrolka pytająca co z tym plikiem
zrobić Otwórz/Zapisz/etc jak to zrobić?

W tej chwili robię to tak:
def getDoc(self):
	id = request.params['doc_id']
       doc = model.meta.Session.query(model.Documents).filter_by(doc_id = id)
.one() #get file from DB
       response.headers['content-type'] = 'application/pdf'
       response.headers['content-length'] = len(doc.doc_content)
       response.headers['content-name'] = self.__getDocumentName__(id)
       return doc.doc_content

Pozdrawiam
Parasit Hendersson
Technical Details
Message-ID: <ido1u5$5ib$1@news2.ipartners.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.internetia.pl!nf1.ipartners.pl!ipartners.pl!news2.ipartners.pl!not-for-mail
From: Parasit Hendersson <parasit_nospam_@go2.pl>
Newsgroups: pl.comp.lang.python
Subject: [pylons] Zwracanie pliku z bazy danych
Date: 8 Dec 2010 13:41:25 GMT
Organization: GTS Energis
Lines: 21
Message-ID: <ido1u5$5ib$1@news2.ipartners.pl>
Reply-To: parasit_nospam_@go2.pl
NNTP-Posting-Host: 217.153.75.233
Mime-Version: 1.0
X-Trace: news2.ipartners.pl 1291815685 5707 217.153.75.233 (8 Dec 2010 13:41:25 GMT)
X-Complaints-To: abuse@ipartners.pl
NNTP-Posting-Date: 8 Dec 2010 13:41:25 GMT
Keywords: pylons database python
User-Agent: slrn/pre1.0.0-18 (Linux)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit