Exemple #1
0
    def create_attachment(self, uploaded_file):
        if not uploaded_file:
            return None

        return AttachmentData(filename=fix_filename(uploaded_file['filename']),
                              mimetype=uploaded_file['content_type'],
                              data=uploaded_file['filedata'])
    def create_attachment(self, uploaded_file):
        if not uploaded_file:
            return None

        return AttachmentData(filename=fix_filename(uploaded_file['filename']),
                              mimetype=uploaded_file['content_type'],
                              data=uploaded_file['filedata'])
Exemple #3
0
def download_content_response(content_type, content, filename=None):
    e = view_content_response(content_type, content)

    # convert filename if necessary
    if isinstance(filename, unicode):
        filename = fix_filename(filename)

    filename = str(filename)

    # consider the response as an attachment (will be downloaded instead of being displayed in the browser)
    content_disposition = "attachment"

    # add filename info
    if filename is not None:
        content_disposition += ';filename="%s"' % filename
        e.filename = filename

    # add content disposition
    e.headers["Content-Disposition"] = content_disposition
    return e
def download_content_response(content_type, content, filename=None):
    e = view_content_response(content_type, content)

    # convert filename if necessary
    if isinstance(filename, unicode):
        filename = fix_filename(filename)

    filename = str(filename)

    # consider the response as an attachment (will be downloaded instead of being displayed in the browser)
    content_disposition = "attachment"

    # add filename info
    if filename is not None:
        content_disposition += ';filename="%s"' % filename
        e.filename = filename

    # add content disposition
    e.headers["Content-Disposition"] = content_disposition
    return e
Exemple #5
0
 def export_xls(self, filename=None, title=_(u'Users')):
     renderer = XLSRenderer()
     self.render_xls(renderer, title)
     timestamp = datetime.now().date().isoformat()
     filename = filename or '%s-%s.xls' % (timestamp, fix_filename(title))
     raise excel_response(renderer.get_content(), filename)
 def export_xls(self, filename=None, title=_(u'Users')):
     renderer = XLSRenderer()
     self.render_xls(renderer, title)
     timestamp = datetime.now().date().isoformat()
     filename = filename or '%s-%s.xls' % (timestamp, fix_filename(title))
     raise excel_response(renderer.get_content(), filename)
Exemple #7
0
 def test_fix_filename(self):
     self.assertEquals('meme.jpg', fix_filename(u'mémé.jpg'))
     self.assertEquals('meme bebe.jpg', fix_filename(u'mémé bébé@.jpg'))