Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21422
| Path | csiph.com!usenet.pasdenom.info!goblin1!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.021 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'wrote:': 0.18; '>>>': 0.18; 'detect': 0.21; 'from:addr:web.de': 0.23; 'skip:m 30': 0.24; 'subject:data': 0.25; 'looks': 0.27; "i'm": 0.28; 'correct': 0.29; 'far,': 0.30; 'header,': 0.30; "i've": 0.32; "can't": 0.33; 'header:User-Agent:1': 0.33; 'it.': 0.33; 'file': 0.34; 'header:X -Complaints-To:1': 0.34; 'to:addr:python-list': 0.35; 'data.': 0.36; 'received:org': 0.36; 'but': 0.37; 'some': 0.38; 'data': 0.38; 'skip:o 20': 0.38; 'might': 0.40; 'to:addr:python.org': 0.40; 'serving': 0.68; 'subject:stream': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Finding MIME type for a data stream |
| Date | Fri, 09 Mar 2012 11:50:04 +0100 |
| Organization | None |
| References | <%U96r.32867$082.25394@newsfe04.iad> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p50849862.dip.t-dialin.net |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.531.1331290226.3037.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1331290226 news.xs4all.nl 6937 [2001:888:2000:d::a6]:56353 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:21422 |
Show key headers only | View raw
Tobiah wrote:
> I'm pulling image data from a database blob, and serving
> it from a web2py app. I have to send the correct
> Content-Type header, so I need to detect the image type.
>
> Everything that I've found on the web so far, needs a file
> name on the disk, but I only have the data.
>
> It looks like the 'magic' package might be of use, but
> I can't find any documentation for it.
After some try-and-error and a look into example.py:
>>> m = magic.open(magic.MAGIC_MIME_TYPE)
>>> m.load()
0
>>> sample = open("tmp.png").read()
>>> m.buffer(sample)
'image/png'
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-08 13:55 -0800
Re: Finding MIME type for a data stream Dave Angel <d@davea.name> - 2012-03-08 17:11 -0500
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-08 14:28 -0800
Re: Finding MIME type for a data stream Dave Angel <d@davea.name> - 2012-03-08 17:56 -0500
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-08 15:40 -0800
Re: Finding MIME type for a data stream Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-03-08 21:04 -0500
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-09 08:40 -0800
Re: Finding MIME type for a data stream Jon Clements <joncle@googlemail.com> - 2012-03-08 18:31 -0800
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-09 09:53 -0800
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-08 14:34 -0800
Re: Finding MIME type for a data stream Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2012-03-09 03:12 +0100
Re: Finding MIME type for a data stream Tobiah <toby@tobiah.org> - 2012-03-09 08:35 -0800
Re: Finding MIME type for a data stream Peter Otten <__peter__@web.de> - 2012-03-09 11:50 +0100
csiph-web