mime

Python: Check if uploaded file is jpg

自闭症网瘾萝莉.ら 提交于 2019-11-26 19:46:08
问题 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. 回答1: 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

Register file extensions / mime types in Linux

允我心安 提交于 2019-11-26 19:32:14
I'm developing a Linux application that has its own file format. I want my app to open when you double-click on those files. How can I register a file extension and associate it with my application on Linux? I'm looking for a way that is standard (works with GNOME and KDE based systems) and can be done automatic when my program is installed or run for the first time. Use xdg-utils from freedesktop.org Portland . Register the icon for the MIME type: xdg-icon-resource install --context mimetypes --size 48 myicon-file-type.png x-application-mytype Create a configuration file ( freedesktop Shared

IIS部署Silverlight

梦想的初衷 提交于 2019-11-26 19:13:56
题设:   网站如果应用了Silverlight技术,直接部署到IIS中是无法正常运行的,   分析:   因为Silverlight应用所对应的三种MIME类型没有在IIS中注册,所以Silverlight相关的文件无法下载到客户端,而Silverlight又是客户端应用,这样网站运行不正常。   解决:   Silverlight的发布涉及三种类型的文件:.xap, .xaml, .xbap,这些后缀名对于IIS6和IIS7来说都是新的,他们对应的MIME类型没有默认被添加到IIS中,所以需要手动进行注册,注册的内容为:   .xap   application/x-silverlight-app   .xaml  application/xaml+xml   .xbap  application/x-ms-xbap   注册MIME类型的方法,打开IIS,在网站或默认网站上右击,选择属性,点击 ‘HTTP头选项卡’找到“MIME类型(M)”按纽,点击进行对MIME类型的新建。添加MIME完成后将网站和对应的应用程序池重启,重新打开网站即恢复正常。   网站如果应用了Silverlight技术,直接部署到IIS中是无法正常运行的,   分析:   因为Silverlight应用所对应的三种MIME类型没有在IIS中注册,所以Silverlight相关的文件无法下载到客户端

python3-邮件发送-不同格式

血红的双手。 提交于 2019-11-26 19:02:18
0x00 邮件格式 要发邮件,总要先了解邮件格式吧,这里指的是邮件的各个部分与python中SMTP所对应的一些必须的格式 0x01 简单发送邮件格式如下: import smtplib from email.mime.text import MIMEText from email.header import Header mail_host = 'smtp.139.com' mail_user = 'xxx@139.com' mail_pass = 'xx' # 邮件定义区域 msg = MIMEText('我是邮件内容','plain','utf-8') # 邮箱正文内容 msg['Subject'] = '我是标题' # msg['From'] = mail_user # 发件人 msg['From'] = '发件人自定义'+'<'+mail_user+'>' msg['To'] = 'xxx@139.com,xxx@163.com' # 收件人 msg['Cc'] = 'xxx@163.com' # 抄送对象 server = smtplib.SMTP() server.connect(mail_host) server.login(mail_user,mail_pass) server.sendmail(msg['From'],msg['To']+msg['Cc']

Nginx fails to load css files

大憨熊 提交于 2019-11-26 18:41:20
I've recently decided to switch from Apache2 to Nginx. I installed Nginx on my CentOS server and setup a basic configuration. When I tried to load my site in browser (FF/Chrome) I noticed that css file is not loaded. I checked the error console and saw this message: Error: The stylesheet http://example.com/style.css was not loaded because its MIME type, "text/html", is not "text/css". I checked Nginx configuration and everything seems to be fine: http { include /etc/nginx/mime.types; .......... } The mime type for css files is correctly set in /etc/nginx/mime.types. text/css css; Everything

How to use the CSV MIME-type?

余生颓废 提交于 2019-11-26 18:39:46
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.0.1 (on linux). The browsers it did not work in were IE 7 and FF 3.0 (on windows) Are there any quirks I am

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

↘锁芯ラ 提交于 2019-11-26 18:24:45
问题 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

How can I detect the current tab's mime type in a Google Chrome extension?

给你一囗甜甜゛ 提交于 2019-11-26 17:45:33
问题 I want to see if the current tab is a PDF file from a background page. I can check the url for .pdf at the end but there are some PDF files that don't have that. 回答1: You can't get it using current Chrome API afaik. What you can do is load this page again through XHR and check returned content-type header. Something like this: background html: chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if(changeInfo.status == "loading") { if(checkIfUrlHasPdfExtension(tab.url)) { //

How do I get File Type Information based on extension? (not MIME) in c#

匆匆过客 提交于 2019-11-26 17:45:17
问题 How do I get the general File type description based on extension like Explorer does it? So not MIME but the information that the end-user sees, like. .doc = Microsoft Office Word 97 - 2003 Document .zip = ZIP File .avi = Video File. And how can I get the 'secondary' information that seems to be available, which I guess it not extension based. Like on "Video Files" it can give you the 'Length' of the movie or on doc files how many pages it has.. etc etc.. 回答1: Thanks Dan, Alright.. This

Send e-mail to Gmail with inline image using Python

走远了吗. 提交于 2019-11-26 16:09:48
问题 My objective is to use Python to send an e-mail to a Gmail user that has an inline image. It is not possible to host this image online and then link to it through a href , due to the sensitive nature of the images (data from my work). I've tried encoding the base64 version into a HTML then sending th is HTML , but this is well known to not work. I then noticed that in Gmail you can drag and drop an image into the send box and it will show up inline in the receiving end. Given this I then