I have a controller that create a new record for a specific model.
This model contains a fields.Binary
.
Here's what the controller looks like:
@http.route('/mymodel/create', type='json', method='POST', auth='user')
def create_record(self, **kwargs):
"""
@params:
'field1': string
'field2': int
'binaryField': binary
"""
values = {'my_model_field_1': kwargs.get('field1'),
'my_model_field_2': kwargs.get('field2'),
'my_model_binary_field': kwargs.get('binaryField')}
request.env['my_model'].create(values)
My question is how should I send my file from the remote app connected to the server?
I'll probably have to send it as a string since it's sent in the json format. How do I have to modify my controller to receive it correctly?
I would be grateful for an example of code converting the file in a string that can be sent throught Json. I'll also have to convert it from any language, as I'm building an API, what is the standard that will be recognized by the binary field?