How to insert more attachments in the same time with Ravendb

Viewed 53

I want to insert these attachments with ravendb, but I get this error:

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.

Code:

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()
1 Answers
Related