mime

How can I query IIS for MIME Type Mappings?

牧云@^-^@ 提交于 2019-11-27 21:46:29
问题 How can I programatically read IIS's MIME types? I'd like to use them when I stream data to my clients using WCF. Any tips, or API would be appreciated 回答1: I'm making the assumption this is IIS7 only and you're using C#3.0 or later: using Microsoft.Web.Administration; .... using(ServerManager serverManager = new ServerManager()) { // If interested in global mimeMap: var config = serverManager.GetApplicationHostConfiguration(); // Use if interested in just a particular site's mimeMap: // var

Best way to handle email parsing/decoding in PHP?

时光总嘲笑我的痴心妄想 提交于 2019-11-27 20:29:37
Currently I'm using the PEAR library's mimeDecode.php for parsing incoming emails. It seems to have a lot of issues and fails to decode a lot of messages, so I'd like to replace it with something better. I'm looking for something that is able to properly separate parts of the message, such as to, from, body, etc. Ideally it would be able to handle all common encoding methods such as base64, uuencode, quoted printable, etc. In situations where both plain text and html versions of the same message are contained in a single email, I would ideally like it to know the difference between them so I

Embedding attached images in HTML emails

混江龙づ霸主 提交于 2019-11-27 20:11:12
If I attach an image to an email, how can I place it in the HTML content? I tried just using the filename as the image source but that doesn't seem to work. Be more specific on how you build the HTML mail message. The result will be a multipart-MIME message with a text/html part (if you really do it right with an alternate part of type text/plain) and several images, which are then referenced from within the HTML. See RFC 1813 and RFC 2378 for more information about content-id in mixed MIME and related data (referred by CID in the HTML source). Maria Rosa Jordán You can use the same way with

How to guess image mime type?

≡放荡痞女 提交于 2019-11-27 19:24:19
问题 How can I guess an image's mime type, in a cross-platform manner, and without any external libraries? 回答1: If you know in advance that you only need to handle a limited number of file formats you can use the imghdr.what function. 回答2: I've checked the popular image types' format on wikipedia, and tried to make a signature: def guess_image_mime_type(f): ''' Function guesses an image mime type. Supported filetypes are JPG, BMP, PNG. ''' with open(f, 'rb') as f: data = f.read(11) if data[:4] ==

Simple C++ MIME parser [closed]

不羁岁月 提交于 2019-11-27 19:12:11
I want to digest a multipart response in C++ sent back from a PHP script. Anyone know of a very lightweight MIME parser which can do this for me? I know this may be too little, too late, but I had a similar need. I wanted a mime parser that just did the encoding and decoding of the MIME. For the sake of completeness and for Google-ability I thought I should put my findings here. Keep in mind that I was not interested in send and receiving mail, just encoding and decode MIME. Here are the libraries I researched for C++ MIME: http://www.vmime.org/ - Looks like too much. Contains pop, SMTP, tls,

Python: Check if uploaded file is jpg

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 19:08:44
How can I check if a file uploaded by a user is a real jpg file in Python (Google App Engine)? This is how far I got by now: Script receives image via HTML Form Post and is processed by the following code ... incomming_image = self.request.get("img") image = db.Blob(incomming_image) ... I found mimetypes.guess_type, but it does not work for me. If you need more than looking at extension, one way would be to read the JPEG header, and check that it matches valid data. The format for this is: Start Marker | JFIF Marker | Header Length | Identifier 0xff, 0xd8 | 0xff, 0xe0 | 2-bytes | "JFIF\0" so a

Base64 decoding of MIME email not working (GMail API)

血红的双手。 提交于 2019-11-27 17:49:06
问题 I'm using the GMail API to retrieve an email contents. I am getting the following base64 encoded data for the body: http://hastebin.com/ovucoranam.md But when I run it through a base64 decoder, it either returns an empty string (error) or something that resembles the HTML data but with a bunch of weird characters. Help? 回答1: I'm not sure if you've solved it yet, but GmailGuy is correct. You need to convert the body to the Base64 RFC 4648 standard. The jist is you'll need to replace - with +

Add mime type to HTML link

本小妞迷上赌 提交于 2019-11-27 15:33:33
问题 I know how to change the MIME type in a webserver. I used this to make sure the browser downloads my .scrpt file instead of opening the plain text version. So far so good but is it possible to do the same with a link? I would like to link to a file on GitHub but this will open as a plain text file. Can I add a "MIME type attribute" to the link to tell the browser to download the file? This is what I would like to see: <a mimetype="application/octet-stream" href="http://gist.github.com/raw

Copying rich text and images from one document to MIME in another document

狂风中的少年 提交于 2019-11-27 14:30:35
I have a solution for copying rich text content from one document to MIME in another document. See http://per.lausten.dk/blog/2012/12/xpages-dynamically-updating-rich-text-content-in-a-ckeditor.html . I use this in an application as a way for the user to insert content templates in a new document and have the content appear on-the-fly in the CKEditor. The problem is that inline images are not included in the copying - only a reference to temporary storage of the images. This means that the images are only visible for the current user in the current session. So not very useful. How can I

Jersey: A message body writer for Java Class and MIME mediatype application/json was not found

只谈情不闲聊 提交于 2019-11-27 14:29:58
问题 after trying to figure out what's my problem I finally decided to ask you how to solve my problem. I've seen different people with the same problem and I tried all the things they were adviced to do but nothing helped with my issue. So basically I'm having a RESTful Service which I build using Jersey. For my client I would like to return an object in JSON Format. I read through different tutorials and decided that it makes sense to use jersey-json-1.8 library. I added everything to my project