diff --git a/medallion/backends/taxii/memory_backend.py b/medallion/backends/taxii/memory_backend.py
index 85ce27f..d0871ee 100644
--- a/medallion/backends/taxii/memory_backend.py
+++ b/medallion/backends/taxii/memory_backend.py
@@ -5,6 +5,8 @@ import logging
 import os
 import re
 
+from six import string_types
+
 from ...exceptions import ProcessingError
 from ...filters.basic_filter import BasicFilter
 from ...utils.common import (create_bundle, datetime_to_string,
@@ -113,13 +115,19 @@ class MemoryBackend(Backend):
             return json.load(infile)
 
     def load_data_from_file(self, filename):
-        with codecs.open(filename, mode="r", encoding="utf8") as infile:
-            self.data = json.load(infile)
+        if isinstance(filename, string_types):
+            with codecs.open(filename, mode="r", encoding="utf8") as infile:
+                self.data = json.load(infile)
+        else:
+            self.data = json.load(filename)
 
     def save_data_to_file(self, filename, **kwargs):
         """The kwargs are passed to ``json.dump()`` if provided."""
-        with codecs.open(filename, mode="w", encoding="utf8") as outfile:
-            json.dump(self.data, outfile, **kwargs)
+        if isinstance(filename, string_types):
+            with codecs.open(filename, mode="w", encoding="utf8") as outfile:
+                json.dump(self.data, outfile, **kwargs)
+        else:
+            json.dump(self.data, filename, **kwargs)
 
     def _get(self, key):
         for ancestors, item in iterpath(self.data):

save_data_to_file() in test_memory_backend fails on Windows
https://github.com/oasis-open/cti-taxii-server/blob/b9441e14b73eefbd5c3b85c6de7a1c4e4db81a8a/medallion/test/test_memory_backend.py#L396-L403

> save_data_to_file(f.name) attempts to open the temporary file, which has already been opened by NamedTemporaryFile.  That doesn't work (at least on Windows), and causes a permission error.
>
> Python docs say: "Whether the name can be used to open the file a second time, while the named temporary file is still open, varies across platforms (it can be so used on Unix; it cannot on Windows NT or later)."
>
> https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile
>
> I think save_data_to_file() should probably be changed to accept a file-like object rather than a filename, akin to json.dump().

Found by @chisholm.
diff --git a/medallion/test/test_memory_backend.py b/medallion/test/test_memory_backend.py
index 5cc5c6c..11e6091 100644
--- a/medallion/test/test_memory_backend.py
+++ b/medallion/test/test_memory_backend.py
@@ -393,15 +393,19 @@ class TestTAXIIServerWithMemoryBackend(TaxiiTest):
         post_header["Content-Type"] = MEDIA_TYPE_STIX_V20
         post_header["Accept"] = MEDIA_TYPE_TAXII_V20
 
-        with tempfile.NamedTemporaryFile() as f:
+        with tempfile.NamedTemporaryFile(mode="w+") as f:
             self.client.post(
                 test.ADD_OBJECTS_EP,
                 data=json.dumps(new_bundle),
                 headers=post_header,
             )
-            self.app.medallion_backend.save_data_to_file(f.name)
+            self.app.medallion_backend.save_data_to_file(f)
             assert os.path.isfile(f.name)
 
+            # seek(0) is needed to reset the file pointer so it's correctly
+            # read by the backend again
+            f.seek(0)
+
             configuration = copy.deepcopy(self.configuration)
             configuration["backend"]["filename"] = f.name
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov responses pymongo pyjwt
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==8.1.8
coverage==7.2.7
dnspython==2.3.0
exceptiongroup==1.2.2
Flask==2.2.5
Flask-HTTPAuth==4.8.0
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
itsdangerous==2.1.2
Jinja2==3.1.6
MarkupSafe==2.1.5
-e git+https://github.com/oasis-open/cti-taxii-server.git@119d8fc6c742931e1e41632cad780c1743425292#egg=medallion
packaging==24.0
pluggy==1.2.0
PyJWT==2.8.0
pymongo==4.7.3
pytest==7.4.4
pytest-cov==4.1.0
pytz==2025.2
PyYAML==6.0.1
requests==2.31.0
responses==0.23.3
six==1.17.0
tomli==2.0.1
types-PyYAML==6.0.12.12
typing_extensions==4.7.1
urllib3==2.0.7
Werkzeug==2.2.3
zipp==3.15.0

name: cti-taxii-server
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - charset-normalizer==3.4.1
      - click==8.1.8
      - coverage==7.2.7
      - dnspython==2.3.0
      - exceptiongroup==1.2.2
      - flask==2.2.5
      - flask-httpauth==4.8.0
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - itsdangerous==2.1.2
      - jinja2==3.1.6
      - markupsafe==2.1.5
      - packaging==24.0
      - pluggy==1.2.0
      - pyjwt==2.8.0
      - pymongo==4.7.3
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.31.0
      - responses==0.23.3
      - six==1.17.0
      - tomli==2.0.1
      - types-pyyaml==6.0.12.12
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - werkzeug==2.2.3
      - zipp==3.15.0
prefix: /opt/conda/envs/cti-taxii-server

medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_saving_data_file
medallion/test/test_memory_backend.py::TestTAXIIWithNoTAXIISection::test_taxii_config_value_taxii medallion/test/test_memory_backend.py::TestTAXIIWithNoAuthSection::test_default_userpass_auth medallion/test/test_memory_backend.py::TestTAXIIWithNoBackendSection::test_server_discovery_backend medallion/test/test_memory_backend.py::TestTAXIIWithNoConfig::test_default_userpass_config medallion/test/test_memory_backend.py::TestTAXIIWithNoConfig::test_server_discovery_backend medallion/test/test_memory_backend.py::TestTAXIIWithNoConfig::test_taxii_config_value_config medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_add_existing_objects medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_add_objects medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_added_after_filtering medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_client_object_versioning medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_api_root_information medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_api_root_information_not_existent medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_collection medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_collection_not_existent medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_collections medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_collections_401 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_collections_404 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_401 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_403 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_404 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_manifest_401 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_manifest_403 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_object_manifest_404 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_objects medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_or_add_objects_401 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_or_add_objects_403 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_or_add_objects_404 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_or_add_objects_422 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_status_401 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_get_status_404 medallion/test/test_memory_backend.py::TestTAXIIServerWithMemoryBackend::test_server_discovery
medallion/backends/taxii/memory_backend.py
medallion/backends/taxii/memory_backend.py