def store_file(self,
                relative_path,
                buf,
                mime_type="application/octet-stream",
                overwrite=False):
     relative_path = pathlib.Path(relative_path)
     file_path = self.base_path / relative_path
     if ".." in file_path.relative_to(self.base_path).parts:
         raise ValueError("only relative paths pointing under base_path "
                          "are accepted")
     mode = "wb" if overwrite else "xb"
     try:
         os.makedirs(str(file_path.parent), exist_ok=True)
         if self.gzip and mime_type not in NO_COMPRESS_MIME_TYPES:
             with gzip.open(
                     str(file_path.with_name(file_path.name + ".gz")),
                     mode) as f:
                 f.write(buf)
         else:
             with file_path.open(mode) as f:
                 f.write(buf)
     except OSError as exc:
         raise DataAccessError("Error storing {0}: {1}".format(
             file_path, exc)) from exc