mime

How can you read a files MIME-type in objective-c

久未见 提交于 2019-11-26 12:11:20
问题 I am interested in detecting the MIME-type for a file in the documents directory of my iPhone application. A search through the docs did not provide any answers. 回答1: It's a bit hacky, but it should work, don't know for sure because I'm just guessing at it There are two options: If you just need the MIME type, use the timeoutInterval: NSURLRequest. If you want the data as well, you should use the commented out NSURLRequest. Make sure to perform the request in a thread though, since it's

Unknown file type MIME?

拜拜、爱过 提交于 2019-11-26 12:07:46
问题 Do I have to specify a MIME type if the uploaded file has no extension? In other words is there a default general MIME type? 回答1: You can use application/octet-stream for unknown types. RFC 2046 states in section 4.5.1: The "octet-stream" subtype is used to indicate that a body contains arbitrary binary data. 回答2: RFC resources: We should use RFC-7231 (HTTP/1.1 Semantics and Content) as reference instead of RFC-2046 (Media Types) because question was clearly about HTTP Content-Type. Also RFC

How can I get an email message's text content using Python?

允我心安 提交于 2019-11-26 12:06:45
问题 Given an RFC822 message in Python 2.6, how can I get the right text/plain content part? Basically, the algorithm I want is this: message = email.message_from_string(raw_message) if has_mime_part(message, \"text/plain\"): mime_part = get_mime_part(message, \"text/plain\") text_content = decode_mime_part(mime_part) elif has_mime_part(message, \"text/html\"): mime_part = get_mime_part(message, \"text/html\") html = decode_mime_part(mime_part) text_content = render_html_to_plaintext(html) else: #

Mail multipart/alternative vs multipart/mixed

会有一股神秘感。 提交于 2019-11-26 11:59:34
When creating email messages you are supposed to set the Content-Type to multipart/alternative when sending HTML and TEXT or multipart/mixed when sending TEXT and attachments. So what do you do if you want to send HTML, Text, and attachments? Use both? Iain I hit this challenge today and I found these answers useful but not quite explicit enough for me. Edit : Just found the Apache Commons Email that wraps this up nicely, meaning you don't need to know below. If your requirement is an email with: text and html versions html version has embedded (inline) images attachments The only structure I

Tomcat 在IE中下载rar文件直接以乱码方式打开解决方案

…衆ロ難τιáo~ 提交于 2019-11-26 11:50:35
这几天一直很纳闷,在Tomcat部署的网站中的下载文件中,如果文件是rar类型的,一点击下载rar文件就直接打开,并且出现乱码,右键另存为浏览器也是默认为html格式,一直以为是浏览器IE的问题,后来发现其实不关浏览器的问题,而是Tomcat服务器配置的问题,具体如下: web.xml文件中配置<mime-mapping>下载文件类型 TOMCAT在默认情况下下载.rar的文件是把文件当作text打开,以至于IE打开RAR文件为乱码,如果遇到这种情况时不必认为是浏览器的问题,大多数浏览器应该不会死皮赖脸地把二进制文件当作文本打开,一般都是服务器给什么浏览器就开什么.解决方法: 打开conf/web.xml,加入下面的代码. < mime - mapping > < extension > doc </ extension > < mime - type > application / msword </ mime - type > </ mime - mapping > < mime - mapping > < extension > xls </ extension > < mime - type > application / msexcel </ mime - type > </ mime - mapping > < mime - mapping > < extension

Get MIME type from filename extension

梦想的初衷 提交于 2019-11-26 10:59:14
How can I get the MIME type from a file extension? For ASP.NET or other The options were changed a bit in ASP.NET Core, here they are ( credits ): new FileExtensionContentTypeProvider().TryGetContentType(fileName, out contentType); (vNext only) Never tested, but looks like you can officially expand the mime types list via the exposed Mappings property. Use the MimeTypes NuGet package Copy the MimeMappings file from the reference source of the .NET Framework For .NET Framework >= 4.5: Use the System.Web.MimeMapping.GetMimeMapping method, that is part of the BCL in .NET Framework 4.5: string

Correct Apache AddType directives for font MIME types

瘦欲@ 提交于 2019-11-26 10:31:21
问题 I’m using @font-face for embedded fonts (thanks Paul Irish). In trying to fix Chrome’s warning about wrong MIME type for woff fonts, I’ve discovered a mass of conflicting suggestions. Everyone seems to agree that .eot fonts (for IE 6-8?) should be served using AddType application/vnd.ms-fontobject .eot For .ttf fonts (older non-IE browsers?) I’ve seen AddType application/x-font-ttf .ttf AddType application/octet-stream .ttf AddType font/truetype .ttf AddType font/ttf .ttf And for .woff fonts

Sending Multipart html emails which contain embedded images

隐身守侯 提交于 2019-11-26 10:09:29
I've been playing around with the email module in python but I want to be able to know how to embed images which are included in the html. So for example if the body is something like <img src="../path/image.png"></img> I would like to embed image.png into the email, and the src attribute should be replaced with content-id . Does anybody know how to do this? Here is an example I found. Recipe 473810: Send an HTML email with embedded image and plain text alternate : HTML is the method of choice for those wishing to send emails with rich text, layout and graphics. Often it is desirable to embed

How to use the CSV MIME-type?

两盒软妹~` 提交于 2019-11-26 06:29:34
问题 In a web application I am working on, the user can click on a link to a CSV file. There is no header set for the mime-type, so the browser just renders it as text. I would like for this file to be sent as a .csv file, so the user can directly open it with calc, excel, gnumeric, etc. header(\'Content-Type: text/csv\'); echo \"cell 1, cell 2\"; This code works as expected on my computer (Isn\'t that how it always is?) but does not work on another computer. My browser is a nightly build of FF 3

embedding image in html email

ⅰ亾dé卋堺 提交于 2019-11-26 06:27:18
I'm trying to send a multipart/related html email with embedded gif images. This email is generated using Oracle PL/SQL. My attempts have failed, with the image showing up as a red X (in Outlook 2007 and yahoo mail) I've been sending html emails for some time, but my requirements are now to use several gif images in the email. I can store these on one of our web servers and just link to them, but many users email clients will not show them automatically and will need to either change settings or manually download them for each email. So, my thoughts are to embed the image. My questions are: