waikato-ufdl / ufdl-python-client

Core Python library for accessing the UFDL backend, managing the communication.
Apache License 2.0
0 stars 0 forks source link

Check handling of spaces in filenames #5

Closed fracpete closed 4 years ago

fracpete commented 4 years ago
csterling commented 4 years ago

Just tested this using the following code:

from ufdl.pythonclient.functional.core import dataset
dataset_pk = ...

# Add a file to the dataset, with a space in the name
FILENAME = "test name with spaces 2"
print(f"Uploading file as '{FILENAME}'")
with open("test.jpg", "rb") as file:
    dataset.add_file(dataset_pk, FILENAME, file)

# Re-download the file
print(f"Re-downloading '{FILENAME}'")
with open("test-redownload.jpg", "wb") as file:
    for chunk in dataset.get_file(dataset_pk, FILENAME):
        file.write(chunk)

and it seems to work in both directions, with the server displaying:

[13/Jul/2020 11:08:42] "POST /v1/core/datasets/2/files/test%20name%20with%20spaces%202 HTTP/1.1" 200 38
[13/Jul/2020 11:08:42] "GET /v1/core/datasets/2/files/test%20name%20with%20spaces%202 HTTP/1.1" 200 512179

@fracpete Can you provide an example of this error occurring?

fracpete commented 4 years ago

I encountered that bug with the java client and just wanted to ensure that the Python client handles.it properly, too. Hence "check" and not "fix". ;-)