code: def _process_files(self, record_id, data):
          
          if self.files:
              assert not self.files.bucket.locked
              self.files.bucket.locked = True
              snapshot = self.files.bucket.snapshot(lock=True)
              data['_files'] = self.files.dumps(bucket=snapshot.id)
              yield data
              db.session.add(RecordsBuckets(
                  record_id=record_id, bucket_id=snapshot.id
              ))
          else:
              yield data
docs: Snapshot bucket and add files in record during first publishing.