Esempio n. 1
0
 def createFile(self, path, title=None):
     obj = self._createObject('File', path, title=title)
     named_file = NamedFile()
     named_file.data = pdf_data
     named_file.filename = u'test.pdf'
     named_file.contentType = u'application/pdf'
     obj.file = named_file
     obj.reindexObject()
Esempio n. 2
0
 def createFile(self, path, title=None):
     obj = self._createObject('File', path, title=title)
     named_file = NamedFile()
     named_file.data = pdf_data
     named_file.filename = u'test.pdf'
     named_file.contentType = u'application/pdf'
     obj.file = named_file
     obj.reindexObject()
Esempio n. 3
0
    def test_xml_binary(self):

        from plone.namedfile import NamedFile

        img_data = open(os.path.join(os.path.dirname(__file__), 'sample.jpg'), 'rb').read()
        named_file = NamedFile()
        named_file.data = img_data
        named_file.filename = u'test.jpg'
        named_file.contentType = 'image/jpg'
        self.doc.xml_set('xml_binary', named_file)

        named_file2 = self.doc.xml_get('xml_binary')
        self.assertEqual(named_file2.data, img_data)
        self.assertEqual(named_file2.filename, u'test.jpg')
        self.assertEqual(named_file2.contentType, 'image/jpg')
    def test_xml_binary(self):

        from plone.namedfile import NamedFile

        img_data = open(os.path.join(os.path.dirname(__file__), 'sample.jpg'),
                        'rb').read()
        named_file = NamedFile()
        named_file.data = img_data
        named_file.filename = u'test.jpg'
        named_file.contentType = 'image/jpg'
        self.doc.xml_set('xml_binary', named_file)

        named_file2 = self.doc.xml_get('xml_binary')
        self.assertEqual(named_file2.data, img_data)
        self.assertEqual(named_file2.filename, u'test.jpg')
        self.assertEqual(named_file2.contentType, 'image/jpg')