@@ -136,6 +136,21 @@ def test_upload_file_with_bytesio(self, api, tmp_path, repo_url):
136136 downloaded_content = f .read ()
137137 assert downloaded_content == self .bin_content
138138
139+ def test_upload_file_with_byte_array (self , api , tmp_path , repo_url ):
140+ repo_id = repo_url .repo_id
141+ content = self .bin_content
142+ with assert_upload_mode ("xet" ):
143+ api .upload_file (
144+ path_or_fileobj = content ,
145+ path_in_repo = "bytearray_file.bin" ,
146+ repo_id = repo_id ,
147+ )
148+ # Download and verify content
149+ downloaded_file = hf_hub_download (repo_id = repo_id , filename = "bytearray_file.bin" , cache_dir = tmp_path )
150+ with open (downloaded_file , "rb" ) as f :
151+ downloaded_content = f .read ()
152+ assert downloaded_content == self .bin_content
153+
139154 def test_fallback_to_lfs_when_xet_not_available (self , api , repo_url ):
140155 repo_id = repo_url .repo_id
141156 with patch ("huggingface_hub.hf_api.is_xet_available" , return_value = False ):
@@ -284,7 +299,7 @@ def test_hf_xet_with_token_refresher(self, api, tmp_path, repo_url):
284299
285300 This test ensures that the downloaded file is the same as the uploaded file.
286301 """
287- from hf_xet import PyPointerFile , download_files
302+ from hf_xet import PyXetDownloadInfo , download_files
288303
289304 filename_in_repo = "binary_file.bin"
290305 repo_id = repo_url .repo_id
@@ -327,13 +342,15 @@ def token_refresher() -> Tuple[str, int]:
327342 mock_token_refresher = MagicMock (side_effect = token_refresher )
328343
329344 incomplete_path = Path (tmp_path ) / "file.bin.incomplete"
330- py_file = [
331- PyPointerFile (path = str (incomplete_path .absolute ()), hash = xet_filedata .file_hash , filesize = expected_size )
345+ file_info = [
346+ PyXetDownloadInfo (
347+ destination_path = str (incomplete_path .absolute ()), hash = xet_filedata .file_hash , file_size = expected_size
348+ )
332349 ]
333350
334351 # Call the download_files function with the token refresher, set expiration to 0 forcing a refresh
335352 download_files (
336- py_file ,
353+ file_info ,
337354 endpoint = xet_connection_info .endpoint ,
338355 token_info = (xet_connection_info .access_token , 0 ),
339356 token_refresher = mock_token_refresher ,
0 commit comments