minio / minio-py

MinIO Client SDK for Python
https://docs.min.io/docs/python-client-quickstart-guide.html
Apache License 2.0
822 stars 318 forks source link

Feature-request: support for the minio client mv command in the python library #1421

Closed bnlawrence closed 3 months ago

bnlawrence commented 3 months ago

As far as I can see, the minio client mv command manages to move data at source: so, for example:

mc mv alias/bucket/object_old_name alias/bucket/object_new_name

does a copy and delete (I understand I can't rename the object in situ), but it does the copy in the infrastructure at alias.

I presume what it's doing is streaming a get to a put? But I'm sure that stream is happening server-side. (There is no way I am getting 70MiB/s on my home broadband). Is there any way to get that to work with this python library? I can't see an obvious solution with what is here now? Nor can I see a methodology by which I could construct a solution to contribute, or am I being dumb?

harshavardhana commented 3 months ago

mv is a high level API - outside the scope of this SDK.

bnlawrence commented 3 months ago

Sorry, I guess my issue was not clear. This is a SDK. I was asking how I can construct a mv operation with this SDK ... is it even possible? One assumes that high level operations are constructed out of building blocks of lower level APIs such as this library? It's fine for you to say: "It's not possible" (though a more helpful answer would be "it's not possible because X"), but I was actually offering to try and construct a solution, if someone would give me some pointers as to how it is done. But I guess you don't really want contributions given this response.

balamurugana commented 3 months ago

@bnlawrence It is just a two liner. Please refer our documentation for each APIs.

result = client.copy_object(
    "my-bucket",
    "my-object",
    CopySource("my-sourcebucket", "my-sourceobject"),
)
print(result.object_name, result.version_id)

client.remove_object("my-sourcebucket", "my-sourceobject")
bnlawrence commented 3 months ago

Thanks @balamurugana. Apologies. That's really embarrassing. I don't know why I didn't see that. I swear I did troll through the docs several times ... but I must have just read the method name and been blind to the words "server-side" ... (I am actively building something with this kit, so I am enough familiar enough with many other methods to have no excuse for this). Again, thanks!

balamurugana commented 3 months ago

@bnlawrence No problem at all