def media_id(self, filename, content_type=None, version=True): """Get media id for given filename. It can be used by async task to first generate id upload file later. :param filename: unique file name """ try: return bson.ObjectId(str(filename)[:24]) # keep content hash except bson.errors.InvalidId: return bson.ObjectId(sha(str(filename))[:24])
def media_id(self, filename, content_type=None): """Get media id for given filename. It can be used by async task to first generate id upload file later. :param filename: unique file name """ try: return bson.ObjectId(str(filename)[:24]) # keep content hash except bson.errors.InvalidId: return bson.ObjectId(sha(str(filename))[:24])
def test_url_for_media(self): _id = bson.ObjectId(sha('test')[:24]) with self.app.app_context(): url = self.media.url_for_media(_id) self.assertEqual('http://localhost/upload-raw/%s' % _id, url)
def test_sha(self): digest = utils.sha("some text") self.assertGreater(len(digest), 40)
def test_sha(self): digest = sha('some text') self.assertGreater(len(digest), 40)
def test_sha(self): digest = utils.sha('some text') self.assertGreater(len(digest), 40)