vaphes / pocketbase

PocketBase client SDK for python
https://pypi.org/project/pocketbase/
MIT License
332 stars 38 forks source link

Trying to upload a single file record uploads of three files with wrong content instead #49

Closed m29h closed 1 year ago

m29h commented 1 year ago

Trying to upload a single file record

  record = client.collection(collid).create(
            {
                "image": FileUpload("filename.txt", "Hello World", "text/plain"),
            }
        )

leads to strange undefined behaviour as instead of creating a single file named filename.txt with content Hello World and text/plain mime-type it counterintuitively uploads three file records (assuming multiple files are allowed for this pocketbase record) The three files are all getting sort of random names like upload_fE6KCgk6LR.txt and have the content of the three strings in FileUpload respectively.

A workaround is to wrap the FileUpload argument into another python list like so: FileUpload( ("filename.txt", "Hello World", "text/plain",) )

I think this is somewhat counter-intuitive