cloud-py-api/nc_py_api

`files.upload_stream` not working with NextCloud 30.0.2 and chunk_size >= 5 * 1024 * 1024

Closed this issue · 1 comments

Describe the bug

Calling files.upload_stream is not working with NextCloud 30.0.2 unless chunk_size is below 5 * 1024 * 1024

Steps/Code to Reproduce

from io import BytesIO

from PIL import Image  # this example requires `pillow` to be installed

import nc_py_api

if __name__ == "__main__":
    nc = nc_py_api.Nextcloud(nextcloud_url="http://nextcloud.local", nc_auth_user="admin", nc_auth_pass="admin")
    buf = BytesIO()
    Image.merge(
        "RGB",
        [
            Image.linear_gradient(mode="L"),
            Image.linear_gradient(mode="L").transpose(Image.ROTATE_90),
            Image.linear_gradient(mode="L").transpose(Image.ROTATE_180),
        ],
    ).save(
        buf, format="PNG"
    )  # saving image to the buffer
    buf.seek(0)  # setting the pointer to the start of buffer
    nc.files.upload_stream("RGB.png", buf)  # uploading file from the memory to the user's root folder
    exit(0)

### Expected Results

File is uploaded successfully

### Actual Results

NextcloudException: [400] Bad Request <upload_stream(v=True): user=admin, path=RGB.png, cur_size=759>

### Setup configuration

nc_py_api = 0.18.0
nextcloud = 30.0.2

in the given example everything works fine for me, both on Nextсloud 30.0.5 RC1 and on the master branch (31.0.0.Beta1)

Could you tell me how I can quickly repeat this error?