Ejemplo n.º 1
0
    def get(self, instance_id):
        if self.is_exist(instance_id) is None:
            abort(404)

        return send_from_directory(
            directory=thumbnail_utils.get_folder_name(self.data_type),
            filename=thumbnail_utils.get_file_name(instance_id)
        )
Ejemplo n.º 2
0
    def get(self, instance_id):
        if not self.is_exist(instance_id):
            abort(404)

        if not self.is_allowed(instance_id):
            abort(403)

        return send_from_directory(
            directory=thumbnail_utils.get_folder_name(self.subfolder),
            filename=thumbnail_utils.get_file_name(instance_id))
Ejemplo n.º 3
0
    def get(self, instance_id):
        if not self.is_exist(instance_id):
            abort(404)

        if not self.is_allowed(instance_id):
            abort(403)

        folder_path = thumbnail_utils.get_preview_folder_name(
            self.subfolder, instance_id)
        file_name = thumbnail_utils.get_file_name(instance_id)

        # Use legacy folder name if the file cannot be found.
        if not os.path.exists(os.path.join(folder_path, file_name)):
            folder_path = thumbnail_utils.get_folder_name("preview-files")

        return send_from_directory(directory=folder_path, filename=file_name)
Ejemplo n.º 4
0
 def test_create_folder(self):
     thumbnail.create_folder("shots")
     folder_name = thumbnail.get_folder_name("shots")
     self.assertTrue(os.path.exists(folder_name))
Ejemplo n.º 5
0
 def test_get_folder_name(self):
     folder_name = thumbnail.get_folder_name("shots")
     expected_result = os.path.join(app.config["THUMBNAIL_FOLDER"], "shots")
     self.assertEqual(folder_name, expected_result)
Ejemplo n.º 6
0
 def tearDown(self):
     super(ThumbnailTestCase, self).tearDown()
     folder_name = thumbnail.get_folder_name("shots")
     fs.rm_rf(folder_name)
     fs.rm_rf(TEST_FOLDER)
     fs.rm_rf(app.config["THUMBNAIL_FOLDER"])
Ejemplo n.º 7
0
 def setUp(self):
     super(ThumbnailTestCase, self).setUp()
     folder_name = thumbnail.get_folder_name("shots")
     fs.rm_rf(folder_name)
Ejemplo n.º 8
0
 def tearDown(self):
     super(ThumbnailTestCase, self).tearDown()
     folder_name = thumbnail.get_folder_name("shots")
     fs.rm_rf(folder_name)