Skip to content

Commit

Permalink
Fix minio path resolution (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
eterna2 committed Jan 15, 2021
1 parent b2af89b commit 43e74db
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# `iotoolz`

## v0.1.0-rc-17

- Fix bug in resolving bucket for `minio://` schema

## v0.1.0-rc-16

- Added `MinioStream` (`minio://`)
Expand Down
8 changes: 4 additions & 4 deletions iotoolz/extensions/minio.py
Expand Up @@ -93,6 +93,7 @@ def __init__(
)

self._scheme, self._endpoint, path, query, _ = urllib.parse.urlsplit(uri)
path = path[1:] if path.startswith("/") else path
self.bucket, *key_chunks = path.split("/")
self.key = "/".join(key_chunks)

Expand All @@ -104,7 +105,7 @@ def __init__(
access_key=access_key or MINIO_ACCESS_KEY,
secret_key=secret_key or MINIO_SECRET_KEY,
region=region or MINIO_REGION,
secure=secure or MINIO_SECURE,
secure=secure if secure is not None else MINIO_SECURE,
)
self._query_str = {
key: value[-1]
Expand Down Expand Up @@ -140,7 +141,6 @@ def read_to_iterable_(
encoding=self.encoding,
etag=etag,
last_modified=last_modified,
extras=resp,
),
)

Expand All @@ -159,7 +159,7 @@ def stats_(self) -> StreamInfo:
content_type=resp.content_type,
etag=resp.etag,
last_modified=resp.last_modified,
extras=resp,
extras={"stat": resp},
)

def exists(self) -> bool:
Expand Down Expand Up @@ -220,7 +220,7 @@ def iter_dir_(self) -> Iterable[StreamInfo]:
name=obj.object_name,
last_modified=obj.last_modified,
etag=obj.etag,
extras=obj,
extras={"list": obj},
)
for obj in objects
)
8 changes: 8 additions & 0 deletions iotoolz/extensions/minio_test.py
@@ -0,0 +1,8 @@
from iotoolz.extensions import MinioStream


def test_minio_path():

stream = MinioStream("minio://endpoint/bucket/folder/key.ext")
assert stream.bucket == "bucket"
assert stream.key == "folder/key.ext"
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iotoolz"
version = "0.1.0-rc-16"
version = "0.1.0-rc-17"
description = "Consistent io iterface to read and write from/to both local and different remote resources (e.g. http, s3, minio)"
keywords = ["io", "stream", "requests", "ftp", "s3", "minio"]
authors = ["eterna2 <eterna2@hotmail.com>"]
Expand Down

0 comments on commit 43e74db

Please sign in to comment.