code: def generate_metadata(self):
          # type: (Descriptor) -> dict
          
          genmeta = {}
          encmeta = {}
          # page align md5
          if (self.must_compute_md5 and
                  self._ase.mode == blobxfer.models.azure.StorageModes.Page):
              aligned = blobxfer.util.page_align_content_length(self._offset)
              diff = aligned - self._offset
              if diff > 0:
                  with self._hasher_lock:
                      self.md5.update(b'\0' * diff)
          # generate encryption metadata
          if self._ase.is_encrypted:
              if self.must_compute_md5:
                  md5digest = blobxfer.util.base64_encode_as_string(
                      self.md5.digest())
              else:
                  md5digest = None
              if self.hmac is not None:
                  hmacdigest = blobxfer.util.base64_encode_as_string(
                      self.hmac.digest())
              else:
                  hmacdigest = None
              encmeta = self._ase.encryption_metadata.convert_to_json_with_mac(
                  md5digest, hmacdigest)
          # generate file attribute metadata
          if self._store_file_attr and not self.local_path.use_stdin:
              merged = blobxfer.models.metadata.generate_fileattr_metadata(
                  self.local_path, genmeta)
              if merged is not None:
                  genmeta = merged
          # generate vectored io metadata
          if self.local_path.view.mode == VectoredIoDistributionMode.Stripe:
              merged = blobxfer.models.metadata.\
                  generate_vectored_io_stripe_metadata(self.local_path, genmeta)
              if merged is not None:
                  genmeta = merged
          if len(encmeta) > 0:
              metadata = encmeta
          else:
              metadata = {}
          if len(genmeta) > 0:
              metadata[blobxfer.models.metadata.JSON_KEY_BLOBXFER_METADATA] = \
                  json.dumps(genmeta, ensure_ascii=False, sort_keys=True)
          if len(metadata) == 0:
              return None
          return metadata
docs: Generate metadata for descriptor
          :param Descriptor self: this
          :rtype: dict or None
          :return: kv metadata dict