Re: [Catalyst] determine MIME type of binary Webservice result?

2010-01-19 Thread Carl Johnstone
Jens Schwarz wrote:
 in my Catalyst application I use Webservices to connect to SAP. One
 of these returns binary data (right now base64-encoded XML, later
 also PDF).

 Is it possible to determine the MIME type of those returned
 (sub)strings? If so, how?

It doesn't matter that you're using Catalyst for this problem.

Your first question should be whether SAP actually returns the data/MIME 
type as part of it's response to your request. If so crib it from there.

If not, you could save the binary data to a file and run some form of 
file-type/magic number detection. If you're running in a unix environment 
you might find the file command useful for this.

Carl


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


RE: [Catalyst] determine MIME type of binary Webservice result?

2010-01-19 Thread Mesdaq, Ali
To do in memory matches I use File::LibMagic on ubuntu box with the latest lib 
magic library installed. 
my $libm = File::LibMagic-new();
my $mtype = $libm-checktype_contents($content);
There is also a method for getting 

Thanks,
--
Ali Mesdaq (CISSP, GIAC-GREM)
Sr. Security Researcher
Websense Security Labs
http://www.WebsenseSecurityLabs.com
--


-Original Message-
From: William Wueppelmann [mailto:william.wueppelm...@canadiana.ca] 
Sent: Tuesday, January 19, 2010 6:39 AM
To: The elegant MVC web framework
Subject: Re: [Catalyst] determine MIME type of binary Webservice result?

On 2010-01-19, at 9:21 AM, Jens Schwarz wrote:

 Hi,
 
 in my Catalyst application I use Webservices to connect to SAP. One of these 
 returns binary data (right now base64-encoded XML, later also PDF).
 
 Is it possible to determine the MIME type of those returned (sub)strings? If 
 so, how?
 
 Thanks
 
 Jens
 -- 
 Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
 http://portal.gmx.net/de/go/dsl02
 
 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/

I am using File::MimeInfo::Magic to determine MIME types for uploaded files. I 
haven't tried to use it with in-memory strings as opposed to on-disk files, but 
the docs for File::MimeInfo say that this is doable.

-William
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


 Protected by Websense Hosted Email Security -- www.websense.com 

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/