I need to upload files to customers in the background. It will be used for uploading patient medical records to a customer record for future reference.
Please advise on how to upload a file to a customer record using python code.
I have tried using the REST API but with no luck.
I have also tried adding a record in the tabFile table and it worked but I wasn’t able to download the file through the interface. It gave an error (403 Forbidden). It seems the file was not registered in the readable list. Also I was not able to delete the attachment through the interface.
You need to convert the file to a base64 encoding, then send using the following PUT command "cmd=uploadfile&doctype=" + myDoctype + "&is_private=1&docname=" + myDocname + "&filename=" + myFilename+"&filedata=" + base64File + "&from_form=1"
where:
myDoctype is the document type to attach to
myDocname is the document name to attach to
myFilename is the name of the attached file
base64File is a string containing the base64 encoded file data
Note that the is_private affects whether anyone can access it or not.
The address you send that command to is your base web path: e.g. beta.erpnext.com