mirror of
https://github.com/moparisthebest/HttpUploadComponent
synced 2024-12-21 23:18:55 -05:00
Merge pull request #22 from chaotix-/mime-content-disposition
Just send Content-disposition: attachment-Header if content is no image
This commit is contained in:
commit
2f0fec6c7f
@ -8,16 +8,12 @@ import mimetypes
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import signal
|
||||
import sleekxmpp
|
||||
import ssl
|
||||
import string
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
from sleekxmpp.componentxmpp import ComponentXMPP
|
||||
from threading import Lock
|
||||
from threading import Thread
|
||||
|
||||
try:
|
||||
# Python 3
|
||||
@ -150,7 +146,8 @@ class HttpHandler(BaseHTTPRequestHandler):
|
||||
if mime is None:
|
||||
mime = 'application/octet-stream'
|
||||
self.send_header("Content-Type", mime)
|
||||
self.send_header("Content-Disposition", 'attachment; filename="{}"'.format(os.path.basename(filename)))
|
||||
if mime[:6] != 'image/':
|
||||
self.send_header("Content-Disposition", 'attachment; filename="{}"'.format(os.path.basename(filename)))
|
||||
fs = os.fstat(f.fileno())
|
||||
self.send_header("Content-Length", str(fs.st_size))
|
||||
self.end_headers()
|
||||
@ -174,7 +171,7 @@ if __name__ == "__main__":
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-c", "--config", default='config.yml', help='Specify alternate config file.')
|
||||
parser.add_argument("-l", "--logfile", default=None, help='File where the server log will be stored. If not specified log to stdout.')
|
||||
parser.add_argument("-l", "--logfile", default=None, help='File where the server log will be stored. If not specified log to stdout.')
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.config,'r') as ymlfile:
|
||||
|
Loading…
Reference in New Issue
Block a user