Exemple #1
0
    def get_encrypted_value(self, value: FieldFile, encryption_key: str):
        file_name = value.name
        value.delete(save=False)
        file = self.get_replacement_file(file_name)

        if func_supports_parameter(value.storage.save, 'max_length'):
            value.name = value.storage.save(file_name,
                                            file,
                                            max_length=value.field.max_length)
        else:
            #  Backwards compatibility removed in Django 1.10
            value.name = value.storage.save(file_name, file)
        setattr(value.instance, value.field.name, value.name)

        value._size = file.size  # Django 1.8 + 1.9
        value._committed = True
        file.close()

        return value