plone / guillotina

Python AsyncIO data API to manage billions of resources
https://guillotina.readthedocs.io/en/latest/
Other
187 stars 51 forks source link

help with @upload #798

Closed jordic closed 4 years ago

jordic commented 4 years ago

It's not so clear how it works from docs:

vangheem commented 4 years ago

For @upload, just send the binary data as the body--that's it.

https://guillotina.readthedocs.io/en/latest/rest/item.html#patch--(db)-(container)-(id)-@upload-(field_name)

It's also the same with postman--just select the file you want to upload and it sends it as the body of the request.

jordic commented 4 years ago

Yup, found it.. it's more a thing around file objects and js.. also found that grange-core is sending them as uuencode strings.. any reason for that? https://github.com/guillotinaweb/grange-core/blob/master/projects/grange-core/src/lib/resource.service.ts#L101

Not pretty sure but I also have to fix the content-type, with a header. Later after downloading the file I also has to revert the uuencode thing.. :/

vangheem commented 4 years ago

it's not converting to unicode, it's converting to base64.

I imagine that's when you want to update the field value directly in a PATCH instead of using the @upload endpoint? \cc @ebrehault

jordic commented 4 years ago

yup, thought the gmi should work directly with bytes.. (closing for the moment)