예제 #1
0
 def test_url_path(self):
     url_path = thumbnail.url_path("shots", "instance-id")
     self.assertEqual(url_path, "pictures/thumbnails/shots/instance-id.png")
     url_path = thumbnail.url_path("working_files", "instance-id")
     self.assertEqual(
         url_path, "pictures/thumbnails/working-files/instance-id.png"
     )
예제 #2
0
    def post(self, instance_id):
        if not self.is_exist(instance_id):
            abort(404)

        self.check_permissions(instance_id)
        self.prepare_creation(instance_id)

        tmp_folder = current_app.config["TMP_DIR"]
        uploaded_file = request.files["file"]
        thumbnail_path = thumbnail_utils.save_file(
            tmp_folder, instance_id, uploaded_file
        )
        thumbnail_path = thumbnail_utils.turn_into_thumbnail(
            thumbnail_path, size=self.size
        )
        file_store.add_picture("thumbnails", instance_id, thumbnail_path)
        os.remove(thumbnail_path)
        self.clear_cache_file(instance_id)

        thumbnail_url_path = thumbnail_utils.url_path(
            self.data_type, instance_id
        )
        self.emit_event(instance_id)

        return {"thumbnail_path": thumbnail_url_path}, 201
예제 #3
0
파일: resources.py 프로젝트: Tesla-Coil/zou
    def post(self, instance_id):
        if not self.is_exist(instance_id):
            abort(404)

        self.check_permissions(instance_id)
        self.prepare_creation(instance_id)
        uploaded_file = request.files["file"]
        thumbnail_utils.save_file(self.data_type,
                                  instance_id,
                                  uploaded_file,
                                  size=self.size)

        thumbnail_url_path = \
            thumbnail_utils.url_path(
                self.data_type,
                instance_id
            )

        return {"thumbnail_path": thumbnail_url_path}, 201
예제 #4
0
    def post(self, instance_id):
        if not self.is_exist(instance_id):
            abort(404)

        uploaded_file = request.files["file"]
        thumbnail_utils.save_file(
            self.data_type,
            instance_id,
            uploaded_file,
            size=self.size
        )

        thumbnail_url_path = \
            thumbnail_utils.url_path(
                self.data_type,
                instance_id
            )
        result = {"thumbnail_path": thumbnail_url_path}

        return result, 201