【问题标题】:how to insert more attachements in the same time with Ravendb如何使用 Ravendb 同时插入更多附件
【发布时间】:2022-08-03 14:34:50
【问题描述】:

我想用 ravendb 插入这些附件,但我遇到了这个问题:

输出:

InvalidOperationException: Can\'t store attachment ok1.jpeg of document InstagramPosts/1313-FF, there is a deferred command registered to create an attachment with the same name.

代码:

buffer = BytesIO()
        buffer.write(open(name, \'rb\').read())
        buffer.seek(0)
        self.session.advanced.attachment.store(self.ID, os.path.basename(name), buffer)
        
        buffer = BytesIO()
        buffer.write(open(\"Media/ok1.jpeg\", \'rb\').read())
        buffer.seek(0)
        self.session.advanced.attachment.store(self.ID, os.path.basename(\"Media/ok1.jpeg\"), buffer)

        
        buffer = BytesIO()
        buffer.write(open(\"Media/ok2.jpeg\", \'rb\').read())
        buffer.seek(0)
        self.session.advanced.attachment.store(self.ID, \"Media/ok2.jpeg\", buffer)
        self.session.save_changes()

    标签: python nosql ravendb


    【解决方案1】:

    我认为您使用的是旧版 pyravendb 包。

    尝试使用ravendb v5.2beta。 (它接近稳定版本)。

    https://pypi.org/project/ravendb/5.2.0b2/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多