Как я могу использовать метод обратного вызова в классе хранения Overwrite для метода сохранения django? - PullRequest
0 голосов
/ 04 февраля 2019

Я хочу вызвать метод обратного вызова, как только я пытаюсь вызвать save mthod моего метода перезаписи, но, похоже, он не работает.

ниже - мой код.

class OverwriteStorage(Storage):

def save(self, name, content, max_length=None, callback=None):
        """
        Save new content to the file specified by name. The content should be
        a proper File object or any Python file-like object, ready to be read
        from the beginning.

        This method is modified to take care of callbacks for S3 storage class of amazon.
        So that user specific callback can be accommodated.
        :param name: name of the file.
        :param content: content of the file
        :param max_length: max length of the file.
        :param callback: callback method.
        :return:
        """

        # Get the proper name for the file, as it will actually be saved.
        if name is None:
            name = content.name

        if not hasattr(content, 'chunks'):
            content = File(content, name)

        name = self.get_available_name(name, max_length=max_length)

        return self._save(name, content, callback=callback)

но когда я пытаюсь вызвать это:

file.file_location.save(name_of_the_file, File(open(str(name_of_the_file), 'r')),callback=ProgressPercentageUpload(name_of_the_file, size_of_the_file))

Выдает ошибку ниже:

TypeError: save() got an unexpected keyword argument 'callback'

Есть ли что-то, что я делаю неправильно?

Спасибо за помощь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...