Skip to content

Uploading files could raise an error #193

Closed
@tobenary

Description

@tobenary

Describe the bug

I'm trying to upload files using the with open method and upload_stream.
When I'm using filepath as str, everything is working as expected, and the file is uploaded.
When using the "with open" as per the docs, I'm getting encoding errors.
ERROR - 'charmap' codec can't decode byte 0x9d in position 30: character maps to

file_path I used:
"C:\nextconnect\00592295\parsed\12_26_2023_12_06PM_Logs (2)_parsed.7z"

Steps/Code to Reproduce

Not working: (both 'rb' and w/o 'rb', plus, I also tried using encoding='utf-8')

with open(seven_z_upload_file, 'rb') as f:
    file_path = file_path_in_str
    nextcloud_file_object = nc.files.upload_stream(file_path, seven_z_upload_file)

logger.info(f"Uploaded {nextcloud_file_object.full_path}")

Working:

file_path = file_path_in_str
nextcloud_file_object = nc.files.upload_stream(file_path, seven_z_upload_file)

logger.info(f"Uploaded {nextcloud_file_object.full_path}")

Expected Results

Upload files when using the with open, as well as w/o it.
@bigcat88 , as per your example in https://stackoverflow.com/a/77242950/6575170 , it is possible.

Actual Results

Getting error codes like 'charmap' codec can't decode byte 0x9d

Setup configuration

nc_py = 0.71

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedFixed in last version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions