filemodels.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:ecs_sclm 作者: meaningful 项目源码 文件源码
def _copy_file(self, destination, overwrite=False):
        """
        Copies the file to a destination files and returns it.
        """

        if overwrite:
            # If the destination file already exists default storage backend
            # does not overwrite it but generates another filename.
            # TODO: Find a way to override this behavior.
            raise NotImplementedError

        src_file_name = self.file.name
        storage = self.file.storages['public' if self.is_public else 'private']

        # This is needed because most of the remote File Storage backend do not
        # open the file.
        src_file = storage.open(src_file_name)
        src_file.open()
        return storage.save(destination, ContentFile(src_file.read()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号