Re: Detecting MIME type of a shared file
Tomeu, The zipfile.is_zipfile(filename) method solved my problem. I was able to successfully share a Zip file between two computers running my activity. Still some kinks to iron out, though. I'll keep your suggestion in mind for the future. Thanks, James Simmons Tomeu Vizoso wrote: On Wed, Mar 19, 2008 at 11:08 PM, James Simmons [EMAIL PROTECTED] wrote: Tomeu and Michael, It turns out Python has a method you can pass a filename to and it will identify if the file is a Zip file or not, based on the magic number, not the filename. It seems to do the trick. As a rule of thumb, I would first try to get a mime-type I can trust, and only if I cannot (I get for example application/octet-stream), I would try to sniff the type. But in your case you may be right by just sniffing it. Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Detecting MIME type of a shared file
On Tue, Mar 18, 2008 at 09:18:05AM -0500, James Simmons wrote: how can I tell what kind of file I am receiving when someone shares a file with me? You might examine python's mimetypes module or the 'file' command. Michael ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Detecting MIME type of a shared file
On Wed, Mar 19, 2008 at 9:43 PM, Michael Stone [EMAIL PROTECTED] wrote: On Tue, Mar 18, 2008 at 09:18:05AM -0500, James Simmons wrote: how can I tell what kind of file I am receiving when someone shares a file with me? You might examine python's mimetypes module or the 'file' command. I think you can also add that mime type to the tube's metadata and read it from the receiving side? Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Detecting MIME type of a shared file
Tomeu and Michael, It turns out Python has a method you can pass a filename to and it will identify if the file is a Zip file or not, based on the magic number, not the filename. It seems to do the trick. Thanks, James Simmons Tomeu Vizoso wrote: On Wed, Mar 19, 2008 at 9:43 PM, Michael Stone [EMAIL PROTECTED] wrote: On Tue, Mar 18, 2008 at 09:18:05AM -0500, James Simmons wrote: how can I tell what kind of file I am receiving when someone shares a file with me? You might examine python's mimetypes module or the 'file' command. I think you can also add that mime type to the tube's metadata and read it from the receiving side? Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel
Re: Detecting MIME type of a shared file
On Wed, Mar 19, 2008 at 11:08 PM, James Simmons [EMAIL PROTECTED] wrote: Tomeu and Michael, It turns out Python has a method you can pass a filename to and it will identify if the file is a Zip file or not, based on the magic number, not the filename. It seems to do the trick. As a rule of thumb, I would first try to get a mime-type I can trust, and only if I cannot (I get for example application/octet-stream), I would try to sniff the type. But in your case you may be right by just sniffing it. Tomeu ___ Devel mailing list Devel@lists.laptop.org http://lists.laptop.org/listinfo/devel