def media_id(self, filename):
        """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):
        """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])
Esempio n. 3
0
 def test_sha(self):
     digest = sha('some text')
     self.assertGreater(len(digest), 40)
Esempio n. 4
0
 def test_sha(self):
     digest = sha('some text')
     self.assertGreater(len(digest), 40)