Skip to content

Commit

Permalink
Implement file uploading for Storage Client
Browse files Browse the repository at this point in the history
  • Loading branch information
dreadatour committed Dec 29, 2024
1 parent cf05881 commit ec29c5d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/datachain/client/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ def open_object(
assert not file.location
return FileWrapper(self.fs.open(self.get_full_path(file.path)), cb) # type: ignore[return-value]

def upload(self, path: str, data: bytes) -> "File":
full_path = self.get_full_path(path)
self.fs.pipe_file(full_path, data)
file_info = self.fs.info(full_path)
return self.info_to_file(file_info, path)

Check warning on line 371 in src/datachain/client/fsspec.py

View check run for this annotation

Codecov / codecov/patch

src/datachain/client/fsspec.py#L368-L371

Added lines #L368 - L371 were not covered by tests

def download(self, file: "File", *, callback: Callback = DEFAULT_CALLBACK) -> None:
sync(get_loop(), functools.partial(self._download, file, callback=callback))

Expand Down

0 comments on commit ec29c5d

Please sign in to comment.