Esempio n. 1
0
    def save(self, type='video', sizes=None, task_name=None):
        self.sizes = sizes or self.sizes
        self.task_name = task_name or self.task_name

        file_object = File(type=type)
        self.buffer.reset()
        file_object.file.put(self.buffer, content_type=self.content_type)
        file_object.save()

        transformations = [
            BatchFileTransformation(name, VideoThumbnail(name, format='png'),
                                    ImageResize(name, format='png', **params))
            for name, params in self.sizes['image'].items()
        ] + [
            Video2Flv(name, **params)
            for name, params in self.sizes['flv'].items()
        ]

        if settings.TASKS_ENABLED.get(self.task_name):
            args = [
                file_object.id,
            ] + transformations
            apply_file_transformations.apply_async(args=args)
        else:
            file_object.apply_transformations(*transformations)
        return file_object
Esempio n. 2
0
    def save(self, type="image", sizes=None, task_name=None):
        self.sizes = sizes or self.sizes
        self.task_name = task_name or self.task_name

        file_object = File(type=type)
        self.buffer.reset()
        file_object.file.put(self.buffer, content_type=self.content_type)
        file_object.save()

        transformations = [ImageResize(name=name, format="png", **params) for name, params in self.sizes.items()]

        if settings.TASKS_ENABLED.get(self.task_name):
            args = [file_object.id] + transformations
            apply_file_transformations.apply_async(args=args)
        else:
            file_object.apply_transformations(*transformations)
        return file_object
Esempio n. 3
0
    def save(self, type="video", sizes=None, task_name=None):
        self.sizes = sizes or self.sizes
        self.task_name = task_name or self.task_name

        file_object = File(type=type)
        self.buffer.seek(0)
        file_object.file.put(self.buffer, content_type=self.content_type)
        file_object.save()

        transformations = [
            BatchFileTransformation(name, VideoThumbnail(name, format="png"), ImageResize(name, format="png", **params))
            for name, params in self.sizes["image"].items()
        ] + [Video2Flv(name, **params) for name, params in self.sizes["flv"].items()]

        if settings.TASKS_ENABLED.get(self.task_name):
            args = [file_object.id] + transformations
            apply_file_transformations.apply_async(args=args)
        else:
            file_object.apply_transformations(*transformations)
        return file_object