Пример #1
0
 def test_is_image(self):
     self.assertFalse(is_image("application/xml"))
     self.assertFalse(is_image("audio/mp4"))
     self.assertFalse(is_image("audio/mpeg"))
     self.assertTrue(is_image("image/x-xcf"))
     self.assertTrue(is_image("image/jpeg"))
     self.assertTrue(is_image("image/png"))
     self.assertTrue(is_image("image/svg+xml"))
Пример #2
0
def GET(data_id):
    binary = _get_binary(data_id)
    
    if binary:
        content_key = binary.content_key
        content_type = binary.content_type
        
        binary.last_access = datetime.utcnow()
        binary.save()
        
        if is_image(content_type):
            return get_image_url(content_key), content_type, const.HTTP_STATUS_302
        else:
            return get(content_key), content_type, const.HTTP_STATUS_200
    else:
        return _error_404_message(data_id), const.CONTENT_TYPE_HTML, const.HTTP_STATUS_404