Skip to content

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

Closed
@Mathieu-Ghaleb

Description

@Mathieu-Ghaleb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions