Upload file with REST Api to custom "Attachment Image" field

I can use cmd=uploadfile with REST Api to upload an image to custom doctype’s “Attachments” section.
(Parameters: https://snag.gy/FkQIRn.jpg )
I also have an “file1” field with Attachment Image type. When I upload image with POST /api/resource/{doctype} command it shows like this https://snag.gy/Q7JHYL.jpg . If I click it I get “The page you are looking for is missing. This could be because it is moved or there is a typo in the link.” error. Also I can’t see it on files directory (I’ve checked public and private files folders under sites) I use POST /api/resource/{doctype} with parameters {“id”: “Robert2”, “pass”: “Test ok3”, “file1”: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAgECWA…}

I can safely use web interface to upload image. It shows like this https://snag.gy/GOC0Wn.jpg and if I click it it shows like this https://snag.gy/45F1nJ.jpg .

Is there anyway to use REST Api to get uploaded files to appear in sites/private/files folder while using custom Attach Image field just like using web interface?

Thanks for wonderful product.

Field Attach Image stores reference to file as url not as base64encode.


  1. uploading file separately (use is_private) and
  2. Attach image url (previously uploaded) to doctype using /api/resource/{doctype}

for better control over uploading files. Write server side API re-using frappe.utils.file_manager


@revant_one Thank you for your suggestion.